Lua Code:
pool = ZO_ControlPool:New(templateName, parentControl, namePrefix)
pool:SetCustomFactoryBehavior(
function (control)
-- custom init called for each new control created (not for each Acquire!)
end)
pool:SetCustomResetBehavior(
function (control)
-- custom cleanup called for each Release
end)
control, key = pool:AcquireObject()
pool:ReleaseObject(key)
pool:ReleaseAllObjects()
templateName ... is the name of a virtual control in XML
parentControl ... optional parent to all controls created by the pool; if it's nil, GuiRoot will be their parent
namePrefix ... optional "prefix" to created controls' names
For example, if parentControl:GetName() == "GridContainer" and namePrefix == "Line", created child controls will be named "GridContainerLine1", "GridContainerLine2", etc. If namePrefix == nil, templateName will be used instead (which makes ugly long names, so I rather use prefix
).
You don't have to maintain a table of active objects unless you want to release them selectively. In this case I think you could just hide the parent control, and only rebuild the grid (ReleaseAllObjects and re-create) when settings change (screen resolution, grid spacing).