Search added to options panel
This commit is contained in:
+32
-18
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
local dversion = 275
|
||||
local dversion = 277
|
||||
local major, minor = "DetailsFramework-1.0", dversion
|
||||
local DF, oldminor = LibStub:NewLibrary (major, minor)
|
||||
|
||||
@@ -4280,27 +4280,32 @@ end
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
--> pool
|
||||
|
||||
do
|
||||
do
|
||||
local get = function(self)
|
||||
local object = tremove(self.notUse, #self.notUse)
|
||||
if (object) then
|
||||
tinsert(self.inUse, object)
|
||||
if (self.onAcquire) then
|
||||
local result, errortext = pcall(self.onAcquire, object)
|
||||
end
|
||||
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)
|
||||
if (self.onAcquire) then
|
||||
local result, errortext = pcall(self.onAcquire, object)
|
||||
end
|
||||
return newObject, true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local get_all_inuse = function(self)
|
||||
return self.inUse;
|
||||
end
|
||||
|
||||
|
||||
local release = function(self, object)
|
||||
for i = #self.inUse, 1, -1 do
|
||||
if (self.inUse[i] == object) then
|
||||
@@ -4308,35 +4313,39 @@ do
|
||||
tinsert(self.notUse, object)
|
||||
break
|
||||
end
|
||||
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
|
||||
|
||||
if (self.onReset) then
|
||||
local result, errortext = pcall(self.onReset, object)
|
||||
end
|
||||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
--return the amount of objects
|
||||
local getamount = function(self)
|
||||
return #self.notUse + #self.inUse, #self.notUse, #self.inUse
|
||||
end
|
||||
|
||||
|
||||
local poolMixin = {
|
||||
Get = get,
|
||||
GetAllInUse = get_all_inuse,
|
||||
@@ -4347,25 +4356,30 @@ do
|
||||
Hide = hide,
|
||||
Show = show,
|
||||
GetAmount = getamount,
|
||||
SetOnReset = function(self, func)
|
||||
self.onReset = func
|
||||
end,
|
||||
SetOnAcquire = function(self, func)
|
||||
self.onAcquire = func
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user