Hi all,
I am currently making an addon that displays all the enemies' unitframe by reproducing nameplates based on
NAME_PLATE_CREATED,
NAME_PLATE_UNIT_ADDED,
NAME_PLATE_UNIT_REMOVED events.
Lua Code:
function AddOn:NAME_PLATE_CREATED(...)
local setting = AddOn.db.global;
-- Create nameplate
local nameplate = CreateFrame("Frame", nil, self);
nameplate:SetSize(setting.width, setting.iconSize);
-- Position each nameplates
local listLength = #self.nameplateList;
if (listLength == 0) then
nameplate:SetPoint("TOP");
else
nameplate:SetPoint("TOP", self.nameplateList[listLength], "BOTTOM", 0, -3);
end
self.nameplateList[listLength + 1] = nameplate;
local health = CreateFrame("StatusBar", nil, nameplate);
health:SetStatusBarTexture(LSM:Fetch("statusbar", setting.texture));
health:SetMinMaxValues(0, 1);
health:SetAllPoints(nameplate);
nameplate.health = health;
-- Adjust the height on nameplate creation
if (listLength == 1) then
self:SetHeight(setting.iconSize);
elseif (listLength > 1) then
self:SetHeight(self:GetHeight() + 3 + setting.iconSize);
end
end
function InitializeHandler()
local setting = AddOn.db.global;
local handler = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate");
handler:SetWidth(setting.width);
handler:CustomSetPoint(setting.point);
RegisterStateDriver(handler, "visibility", "[petbattle] hide; show");
AddOn.handler = handler;
handler.nameplateList = {};
end
I am aware of that this taint is occurring because the new nameplates are being created and the height is set while in the combat.
+ The reason that I am using
SecureHandlerStateTemplate is to hide such frame while in a pet battle (as it is shown in L#40).
Is there any possible solution to prevent such taint occurring? Or should I only use my
handler only to hide/show the frame in/out of pet battle, and create another frame on top of it which manages visual part?
Thank you!