Thanks a lot for the replies and help guys. Xrystal - thank you, helps me understand what was going wrong and I was able to look into the right area. Fizzlemizz thank you for helping me with the code as well.
I have had to modify it slightly as the Text font wasn't actually updating to the values I wanted. The modification below:
Lua Code:
local function UpdateTHF()
TalkingHeadFrame.BackgroundFrame:SetAlpha(0) -- adjust the TH frame
TalkingHeadFrame.MainFrame.CloseButton:Hide()
TalkingHeadFrame.NameFrame.Name:SetTextColor(1, 0.82, 0.02)
TalkingHeadFrame.NameFrame.Name:SetShadowColor(0, 0, 0, 1)
TalkingHeadFrame.NameFrame.Name:SetShadowOffset(2, -2)
TalkingHeadFrame.TextFrame.Text:SetTextColor(255,255,255)
TalkingHeadFrame.TextFrame.Text:SetShadowColor(0, 0, 0, 1)
TalkingHeadFrame.TextFrame.Text:SetShadowOffset(2, -2)
end
local function main(self, event, ...)
local addon = ... -- Check for the addon that has just loaded
if addon ~= "Blizzard_TalkingHeadUI" then return end -- Not the TH addon so scram
self:UnregisterAllEvents() -- Is the TH addon so we no longer need to check for addons loading
TalkingHeadFrame:HookScript("OnShow", UpdateTHF);
UpdateTHF();
end
local f = CreateFrame("Frame") -- frame to listen for the registered event(s)
f:RegisterEvent("ADDON_LOADED")
f:SetScript("OnEvent", main)
With the above - the first time the Talking Head appears - the styling is perfect. Any subsequent messages do not appear to retain the "Text" styling but keeps the
Lua Code:
TalkingHeadFrame.BackgroundFrame:SetAlpha(0) -- adjust the TH frame
TalkingHeadFrame.MainFrame.CloseButton:Hide()
I have looked at how other AddOn authors have modified the TH frame and using their methods I was able to style it correctly (although a lot of the code is "merged together" with my styling so I may not be doing this efficiently).
Below is my completed one - any recommendations or improvements will be much appreciated.
Lua Code:
-- Event handler table.
local OnEvent = {};
-- TalkingHeadFrame hook variables.
local AddOn_Loaded, Hooked = false, false;
local function UpdateTHF()
if(AddOn_Loaded) then
TalkingHeadFrame.MainFrame.CloseButton:Hide()
TalkingHeadFrame.NameFrame.Name:SetTextColor(1, 0.82, 0.02)
TalkingHeadFrame.NameFrame.Name:SetShadowColor(0, 0, 0, 1)
TalkingHeadFrame.NameFrame.Name:SetShadowOffset(2, -2)
TalkingHeadFrame.TextFrame.Text:SetTextColor(255,255,255)
TalkingHeadFrame.TextFrame.Text:SetShadowColor(0, 0, 0, 1)
TalkingHeadFrame.TextFrame.Text:SetShadowOffset(2, -2)
TalkingHeadFrame.BackgroundFrame:SetAlpha(0)
end
end
-- Fires when the talking head appears.
OnEvent["TALKINGHEAD_REQUESTED"] = function(self, ...)
if TalkingHeadFrame then
TalkingHeadFrame:HookScript("OnShow", UpdateTHF);
UpdateTHF();
end
end
local function Initialize()
-- Event frame
local frame = CreateFrame("Frame");
frame:SetScript("OnEvent", function(self, event, ...) OnEvent[event](self, ...); end);
for event, func in pairs(OnEvent) do
frame:RegisterEvent(event);
end
AddOn_Loaded = true;
end
Initialize();