Skip to content

Commit

Permalink
Added ignore npc table
Browse files Browse the repository at this point in the history
- Can be added anywhere using /run Details.npcid_ignored[npcid] = true
- Framework and Localization update.
  • Loading branch information
Tercioo committed Apr 21, 2020
1 parent e2a169a commit 2149413
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 11 deletions.
88 changes: 87 additions & 1 deletion Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

local dversion = 178
local dversion = 179

local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
Expand Down Expand Up @@ -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

Loading

0 comments on commit 2149413

Please sign in to comment.