Added ignore npc table

- Can be added anywhere using /run Details.npcid_ignored[npcid] = true
- Framework and Localization update.
This commit is contained in:
Tercio Jose
2020-04-21 14:03:46 -03:00
parent e2a169aa72
commit 2149413da3
4 changed files with 126 additions and 11 deletions
+87 -1
View File
@@ -1,5 +1,5 @@
local dversion = 178
local dversion = 179
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
@@ -3781,3 +3781,89 @@ function DF:IsUnitTapDenied (unitId)
end
-----------------------------------------------------------------------------------------------------------------------------------------------------------
--> pool
do
local get = function(self)
local object = tremove(self.notUse, #self.notUse)
if (object) then
tinsert(self.inUse, object)
return object, false
else
--need to create the new object
local newObject = self.newObjectFunc(self, unpack(self.payload))
if (newObject) then
tinsert(self.inUse, newObject)
return object, true
end
end
end
local release = function(self, object)
for i = #self.inUse, 1, -1 do
if (self.inUse[i] == object) then
tremove(self.inUse, i)
tinsert(self.notUse, object)
break
end
end
end
local reset = function(self)
for i = #self.inUse, 1, -1 do
local object = tremove(self.inUse, i)
tinsert(self.notUse, object)
end
end
--only hide objects in use, do not disable them
local hide = function(self)
for i = #self.inUse, 1, -1 do
self.inUse[i]:Hide()
end
end
--only show objects in use, do not enable them
local show = function(self)
for i = #self.inUse, 1, -1 do
self.inUse[i]:Show()
end
end
--return the amount of objects
local getamount = function(self)
return #self.notUse + #self.inUse
end
local poolMixin = {
Get = get,
Acquire = get,
Release = release,
Reset = reset,
ReleaseAll = reset,
Hide = hide,
Show = show,
GetAmount = getamount,
}
function DF:CreatePool(func, ...)
local t = {}
DetailsFramework:Mixin(t, poolMixin)
t.inUse = {}
t.notUse = {}
t.newObjectFunc = func
t.payload = {...}
return t
end
--alias
function DF:CreateObjectPool(func, ...)
return DF:CreatePool(func, ...)
end
end