Hi
I have a wierd bug with my addon and I have really no idea how to fix it. First how it works:
Once you get to combat addon scans your action bars and remebers them by spell that are on specific button. If external module (ex. TDDps_Warlock) calls for a glowing a button, main addon (TDDps) creates overlay on specific button spell (ex Immolate) and shows a glow on it. Everything works EXCEPT changing specializations.
I am listening on 'PLAYER_TALENT_UPDATE' event and calling TDDps_DisableAddon();. Enable/disable/init sequence is like this:
Lua Code:
----------------------------------------------
-- Disable dps addon functionality
----------------------------------------------
function TDDps_DisableAddon()
if _TD['DPS_Enabled'] == 0 then
return;
end
TDButton_DestroyAllOverlays();
print(_tdInfo .. TDDpsName .. ': Disabling');
TDDps_Frame:SetScript('OnUpdate', nil);
DPS_Skill = nil;
TDDps_Frame.rotationEnabled = false;
_TD['DPS_Enabled'] = 0;
end
----------------------------------------------
-- Initialize dps addon functionality
----------------------------------------------
function TDDps_InitAddon()
TDDps_Frame:Show();
TDDps_Frame:RegisterEvent('PLAYER_TARGET_CHANGED');
TDDps_Frame:RegisterEvent('PLAYER_TALENT_UPDATE');
TDDps_Frame:RegisterEvent('PLAYER_REGEN_DISABLED');
TDDps_Frame:RegisterEvent('PLAYER_REGEN_ENABLED');
TDDps_Frame:SetScript('OnEvent', TDDps_OnEvent);
print(_tdInfo .. TDDpsName .. ': Initialized');
end
----------------------------------------------
-- Enable dps addon functionality
----------------------------------------------
function TDDps_EnableAddon(mode)
print(_tdInfo .. TDDpsName .. ': Enabling');
if _TD['DPS_NextSpell'] == nil then
print(_tdError .. TDDpsName .. ': No addon selected, cannot enable');
return;
end
if _TD['DPS_Enabled'] == 1 then
return;
end
_TD['DPS_Mode'] = mode;
TDButton_Fetch();
if _TD['DPS_OnEnable'] then
_TD['DPS_OnEnable']();
end
TDDps_Frame:SetScript('OnUpdate', TDDps_OnUpdate);
_TD['DPS_Enabled'] = 1;
print(_tdSuccess .. TDDpsName .. ': Enabled');
end
Event system seems to be working fine. I think I have a problem with reusing frames becasue when i change specialization and enter combat 'PLAYER_REGEN_DISABLED' some wierd things are going. Spells are either not overlaying or some random spells are.
Here is my reusing frames system:
Lua Code:
TDButton_FramePool = {};
TDButton_Frames = {};
function TDButton_CreateOverlay(parent, id, texture, r, g, b)
local frame = tremove(TDButton_FramePool);
if not frame then
frame = CreateFrame('Frame', 'TDButton_Overlay_' .. id, parent);
else
frame:SetAttribute('name', 'TDButton_Overlay_' .. id);
end
frame:SetParent(parent);
frame:SetFrameStrata('HIGH');
frame:SetPoint('CENTER', 0, 0);
frame:SetWidth(parent:GetWidth() * 1.4);
frame:SetHeight(parent:GetHeight() * 1.4);
local t = frame.texture;
if not t then
t = frame:CreateTexture('GlowOverlay', 'OVERLAY');
end
t:SetTexture(texture or TDDps_Options_GetTexture());
t:SetBlendMode('ADD');
t:SetAllPoints(frame);
t:SetVertexColor(
r or TDDps_Options.highlightColor.r,
g or TDDps_Options.highlightColor.g,
b or TDDps_Options.highlightColor.b,
TDDps_Options.highlightColor.a
);
frame.texture = t;
tinsert(TDButton_Frames, frame);
return frame;
end
function TDButton_DestroyAllOverlays()
local frame;
for key, frame in pairs(TDButton_Frames) do
frame:Hide();
end
for key, frame in pairs(TDButton_Frames) do
tinsert(TDButton_FramePool, frame);
TDButton_Frames[key] = nil;
end
end
Any idea what I might be doing wrong here?