feat: reformat error messages, update atween
This commit is contained in:
parent
3318270c3d
commit
458477d7c8
6 changed files with 143 additions and 113 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Plugin",
|
"name": "Quad",
|
||||||
"tree": {
|
"tree": {
|
||||||
"$properties": {
|
"$properties": {
|
||||||
"Name": "Quad"
|
"Name": "Quad"
|
||||||
},
|
},
|
||||||
"$path": "src"
|
"$path": "src"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
158
src/mount.lua
158
src/mount.lua
|
|
@ -1,93 +1,93 @@
|
||||||
local module = {};
|
local module = {};
|
||||||
|
|
||||||
function module.init(shared)
|
function module.init(shared)
|
||||||
local new = {};
|
local new = {};
|
||||||
local insert = table.insert;
|
local insert = table.insert;
|
||||||
|
|
||||||
local mountClass = {};
|
local mountClass = {};
|
||||||
mountClass.__index = mountClass;
|
mountClass.__index = mountClass;
|
||||||
function mountClass:unmount()
|
function mountClass:unmount()
|
||||||
local this = self.this
|
local this = self.this
|
||||||
local typeThis = type(this);
|
local typeThis = type(this);
|
||||||
if typeThis == "userdata" then
|
if typeThis == "userdata" then
|
||||||
this:Destroy();
|
this:Destroy();
|
||||||
elseif typeThis == "table" then
|
elseif typeThis == "table" then
|
||||||
pcall(function()
|
pcall(function()
|
||||||
this.Parent = nil;
|
this.Parent = nil;
|
||||||
end);
|
end);
|
||||||
local destroyThis = this.Destroy;
|
local destroyThis = this.Destroy;
|
||||||
if destroyThis then
|
if destroyThis then
|
||||||
pcall(destroyThis,this);
|
pcall(destroyThis,this);
|
||||||
end
|
end
|
||||||
--if sef.to when
|
--if sef.to when
|
||||||
-- todo for remove child on parent
|
-- todo for remove child on parent
|
||||||
end
|
end
|
||||||
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;
|
return (type(item) == "table") and (item._holder or item.holder or item.__holder) or item;
|
||||||
end
|
end
|
||||||
local getHolder = new.getHolder;
|
local getHolder = new.getHolder;
|
||||||
|
|
||||||
-- we should add plugin support
|
-- we should add plugin support
|
||||||
function new.mount(to,this,holder)
|
function new.mount(to,this,holder)
|
||||||
local thisObject = this;
|
local thisObject = this;
|
||||||
if type(this) == "table" then
|
if type(this) == "table" then
|
||||||
thisObject = rawget(this,"__object");
|
thisObject = rawget(this,"__object");
|
||||||
local parent = rawget(this,"__parent");
|
local parent = rawget(this,"__parent");
|
||||||
if type(parent) == "table" then
|
if type(parent) == "table" then
|
||||||
local parentChild = rawget(parent,"__child");
|
local parentChild = rawget(parent,"__child");
|
||||||
if parentChild then
|
if parentChild then
|
||||||
for i,v in pairs(parentChild) do
|
for i,v in pairs(parentChild) do
|
||||||
if v == this then
|
if v == this then
|
||||||
parentChild[i] = nil;
|
parentChild[i] = nil;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rawset(this,"__parent",to);
|
rawset(this,"__parent",to);
|
||||||
end
|
end
|
||||||
if thisObject then
|
if thisObject then
|
||||||
thisObject.Parent = holder or getHolder(to);
|
thisObject.Parent = holder or getHolder(to);
|
||||||
else
|
else
|
||||||
this.Parent = holder or getHolder(to);
|
this.Parent = holder or getHolder(to);
|
||||||
end
|
end
|
||||||
if type(to) == "table" then
|
if type(to) == "table" then
|
||||||
local child = rawget(to,"__child");
|
local child = rawget(to,"__child");
|
||||||
if not child then
|
if not child then
|
||||||
child = {};
|
child = {};
|
||||||
rawset(to,"__child",child);
|
rawset(to,"__child",child);
|
||||||
end
|
end
|
||||||
insert(child,this);
|
insert(child,this);
|
||||||
end
|
end
|
||||||
return setmetatable({to = to,this = this},mountClass);
|
return setmetatable({to = to,this = this},mountClass);
|
||||||
end
|
end
|
||||||
local mount = new.mount;
|
local mount = new.mount;
|
||||||
|
|
||||||
local pack = table.pack;
|
local pack = table.pack;
|
||||||
local mountsClass = {};
|
local mountsClass = {};
|
||||||
mountsClass.__index = mountsClass;
|
mountsClass.__index = mountsClass;
|
||||||
function mountsClass:unmount()
|
function mountsClass:unmount()
|
||||||
for _,v in ipairs(self) do
|
for _,v in ipairs(self) do
|
||||||
v:unmount();
|
v:unmount();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
setmetatable(new,{
|
setmetatable(new,{
|
||||||
__call = function (self,to,...)
|
__call = function (self,to,...)
|
||||||
if select("#",...) == 1 then
|
if select("#",...) == 1 then
|
||||||
return new.mount(to,...);
|
return new.mount(to,...);
|
||||||
end
|
end
|
||||||
local mounts = {};
|
local mounts = {};
|
||||||
local items = pack(...);
|
local items = pack(...);
|
||||||
for _,item in ipairs(items) do
|
for _,item in ipairs(items) do
|
||||||
insert(mounts,mount(to,item));
|
insert(mounts,mount(to,item));
|
||||||
end
|
end
|
||||||
setmetatable(mounts,mountsClass);
|
setmetatable(mounts,mountsClass);
|
||||||
return mounts;
|
return mounts;
|
||||||
end;
|
end;
|
||||||
});
|
});
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
end
|
end
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,30 @@
|
||||||
-- now, we can call modules with string path
|
-- now, we can call modules with string path
|
||||||
|
|
||||||
if (not workspace) and (not game) and (not script) then
|
if (not workspace) and (not game) and (not script) then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
return function (query)
|
return function (query)
|
||||||
local typeQuery = type(query);
|
local typeQuery = type(query);
|
||||||
|
|
||||||
if typeQuery == "string" then
|
if typeQuery == "string" then
|
||||||
local object = script.Parent;
|
local object = script.Parent;
|
||||||
query = query:gsub("/",".");
|
query = query:gsub("/",".");
|
||||||
-- local index = 0;
|
-- local index = 0;
|
||||||
query:gsub("[^%.]+",function (this)
|
query:gsub("[^%.]+",function (this)
|
||||||
-- index = index + 1;
|
-- index = index + 1;
|
||||||
-- if index == 1 and this == "src" then
|
-- if index == 1 and this == "src" then
|
||||||
-- return;
|
-- return;
|
||||||
-- end
|
-- end
|
||||||
local lastObject = object;
|
local lastObject = object;
|
||||||
object = object[this];
|
object = object[this];
|
||||||
if not object then
|
if not object then
|
||||||
object = lastObject.libs
|
object = lastObject.libs
|
||||||
error(("[require] : object %s was not found from this worktree, require failed"):format(query));
|
error(("[require] : object %s was not found from this worktree, require failed"):format(query));
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
return require(object);
|
return require(object);
|
||||||
elseif typeQuery == "userdata" then
|
elseif typeQuery == "userdata" then
|
||||||
return require(query);
|
return require(query);
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue