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,9 +1,9 @@
{
"name": "Plugin",
"name": "Quad",
"tree": {
"$properties": {
"Name": "Quad"
},
"$path": "src"
}
}
}

View file

@ -66,7 +66,7 @@ function module.init(shared)
local isImage = (ClassName == "ImageLabel" or ClassName == "ImageButton");
if (index == "RoundSize" or index == "roundSize") and isImage 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
round.setRound(item,value);
elseif index == "UiRoundSize" or index == "uiRoundSize" or index == "UIRoundSize" then
@ -135,7 +135,7 @@ function module.init(shared)
end
if not item then -- if cannot make new object, ignore this call
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
-- set property and adding child and binding functions
@ -190,7 +190,7 @@ function module.init(shared)
end
if tween 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
local ended, onStepped;
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 으로 지정
function module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter,_)
-- 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
@ -291,26 +291,50 @@ function module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter,_)
-- 스캐줄에 등록
insert(BindedFunctions,Step)
FunctionTargetItem[Step] = Item
return Step
end
-- 여러개의 개체를 트윈시킴
function module.RunTweens(Items,Data,Properties,Ended,OnStepped,Setter,Getter,_)
-- 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
module.RunTween(Item,Data,Properties,Ended,OnStepped,Setter,Getter)
end
end
-- 트윈 멈추기
function module.StopTween(Item,_)
if Item == module then Item = _ end
module.PlayIndex[Item] = nil
function module.StopTween(ItemOrStep,_)
if ItemOrStep == module then warn "AdvancedTween:StopTween() is deprecated, You can use AdvancedTween.StopTween() instead"; ItemOrStep = _ end
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
-- 해당 개체가 트윈중인지 반환
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
return false
@ -326,7 +350,7 @@ end
-- 해당 개체의 해당 프로퍼티가 트윈중인지 반환
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
return false
@ -359,4 +383,8 @@ script.Destroying:Connect(function()
Stepped.UnbindAll()
end)
function module.Destroy()
Stepped.UnbindAll()
end
return module

View file

@ -1,93 +1,93 @@
local module = {};
function module.init(shared)
local new = {};
local insert = table.insert;
local new = {};
local insert = table.insert;
local mountClass = {};
mountClass.__index = mountClass;
function mountClass:unmount()
local this = self.this
local typeThis = type(this);
if typeThis == "userdata" then
this:Destroy();
elseif typeThis == "table" then
pcall(function()
this.Parent = nil;
end);
local destroyThis = this.Destroy;
if destroyThis then
pcall(destroyThis,this);
end
--if sef.to when
-- todo for remove child on parent
end
end
local mountClass = {};
mountClass.__index = mountClass;
function mountClass:unmount()
local this = self.this
local typeThis = type(this);
if typeThis == "userdata" then
this:Destroy();
elseif typeThis == "table" then
pcall(function()
this.Parent = nil;
end);
local destroyThis = this.Destroy;
if destroyThis then
pcall(destroyThis,this);
end
--if sef.to when
-- todo for remove child on parent
end
end
function new.getHolder(item)
function new.getHolder(item)
return (type(item) == "table") and (item._holder or item.holder or item.__holder) or item;
end
local getHolder = new.getHolder;
-- we should add plugin support
function new.mount(to,this,holder)
local thisObject = this;
if type(this) == "table" then
thisObject = rawget(this,"__object");
local parent = rawget(this,"__parent");
if type(parent) == "table" then
local parentChild = rawget(parent,"__child");
if parentChild then
for i,v in pairs(parentChild) do
if v == this then
parentChild[i] = nil;
end
end
end
end
rawset(this,"__parent",to);
end
if thisObject then
thisObject.Parent = holder or getHolder(to);
else
this.Parent = holder or getHolder(to);
end
if type(to) == "table" then
local child = rawget(to,"__child");
if not child then
child = {};
rawset(to,"__child",child);
end
insert(child,this);
end
return setmetatable({to = to,this = this},mountClass);
end
local mount = new.mount;
-- we should add plugin support
function new.mount(to,this,holder)
local thisObject = this;
if type(this) == "table" then
thisObject = rawget(this,"__object");
local parent = rawget(this,"__parent");
if type(parent) == "table" then
local parentChild = rawget(parent,"__child");
if parentChild then
for i,v in pairs(parentChild) do
if v == this then
parentChild[i] = nil;
end
end
end
end
rawset(this,"__parent",to);
end
if thisObject then
thisObject.Parent = holder or getHolder(to);
else
this.Parent = holder or getHolder(to);
end
if type(to) == "table" then
local child = rawget(to,"__child");
if not child then
child = {};
rawset(to,"__child",child);
end
insert(child,this);
end
return setmetatable({to = to,this = this},mountClass);
end
local mount = new.mount;
local pack = table.pack;
local mountsClass = {};
mountsClass.__index = mountsClass;
function mountsClass:unmount()
for _,v in ipairs(self) do
v:unmount();
end
end
setmetatable(new,{
__call = function (self,to,...)
if select("#",...) == 1 then
return new.mount(to,...);
end
local mounts = {};
local items = pack(...);
for _,item in ipairs(items) do
insert(mounts,mount(to,item));
end
setmetatable(mounts,mountsClass);
return mounts;
end;
});
local pack = table.pack;
local mountsClass = {};
mountsClass.__index = mountsClass;
function mountsClass:unmount()
for _,v in ipairs(self) do
v:unmount();
end
end
setmetatable(new,{
__call = function (self,to,...)
if select("#",...) == 1 then
return new.mount(to,...);
end
local mounts = {};
local items = pack(...);
for _,item in ipairs(items) do
insert(mounts,mount(to,item));
end
setmetatable(mounts,mountsClass);
return mounts;
end;
});
return new;
return new;
end
return module;

View file

@ -2,30 +2,30 @@
-- now, we can call modules with string path
if (not workspace) and (not game) and (not script) then
return;
return;
end
return function (query)
local typeQuery = type(query);
local typeQuery = type(query);
if typeQuery == "string" then
local object = script.Parent;
query = query:gsub("/",".");
-- local index = 0;
query:gsub("[^%.]+",function (this)
-- index = index + 1;
-- if index == 1 and this == "src" then
-- return;
-- end
local lastObject = object;
object = object[this];
if not object then
object = lastObject.libs
error(("[require] : object %s was not found from this worktree, require failed"):format(query));
end
end);
return require(object);
elseif typeQuery == "userdata" then
return require(query);
end
if typeQuery == "string" then
local object = script.Parent;
query = query:gsub("/",".");
-- local index = 0;
query:gsub("[^%.]+",function (this)
-- index = index + 1;
-- if index == 1 and this == "src" then
-- return;
-- end
local lastObject = object;
object = object[this];
if not object then
object = lastObject.libs
error(("[require] : object %s was not found from this worktree, require failed"):format(query));
end
end);
return require(object);
elseif typeQuery == "userdata" then
return require(query);
end
end;

View file

@ -107,7 +107,9 @@ function module.init(shared)
tween = function (s,value)
return setmetatable({tvalue = value},{__index = s});
end;
---@deprecated
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});
end;
add = function (s,value)