Hello,
Im currently working on a mouse over chat:
Lua Code:
local CORE = LybrialUI:GetCore();
local FRAMES = CORE.FRAMES;
LybrialChat = LybrialUI:NewModule("Lybrial Chat", "AceHook-3.0");
local LybrialChat = LybrialChat;
LybrialChat.frame = nil;
LybrialChat.chatFrames = {};
LybrialChat.fadOut = true;
LybrialChat.interval = 0.1;
LybrialChat.elapsed = 0;
-- Lua Functions
local _G = _G;
local pairs = pairs;
-- WOW API
local C_PetBattles = C_PetBattles;
local InCombatLockdown = InCombatLockdown;
local NUM_CHAT_WINDOWS = NUM_CHAT_WINDOWS;
local tinsert = tinsert;
function LybrialChat:OnInitialize()
self.frame = FRAMES:CreateFrame("Frame", "LybrialUIChatFrame", FRAMES.UIParent, true);
self:InitializeChatFrames();
self:OnUpdate();
end
function LybrialChat:InitializeChatFrames()
tinsert(self.chatFrames, _G["ChatFrameChannelButton"]);
tinsert(self.chatFrames, _G["ChatFrameMenuButton"]);
tinsert(self.chatFrames, _G["QuickJoinToastButton"]);
for _, frame in pairs(self.chatFrames) do
frame.setParent = true;
end
end
function LybrialChat:OnEnable()
self.frame:SetScript("OnEnter", function(self)
self:SetMouseOverFade(true, true, true);
end);
self.frame:SetScript("OnLeave", function(self)
self:SetMouseOverFade(true, true, false);
end);
self.frame:SetScript("OnUpdate", self.GetChatFrames);
end
function LybrialChat:OnUpdate()
self:OnUpdateChatFrames();
self:OnUpdateHooks();
end
function LybrialChat:OnUpdateChatFrames()
for _, frame in pairs(self.chatFrames) do
if (frame.setParent) then
frame:SetParent(self.frame);
end
end
self.frame:Show();
if (self.fadOut) then
self.fadOut = false;
self.frame:SetMouseOverFade(true, true, false);
end
end
function LybrialChat:OnUpdateHooks()
if (self.db.profile.enabled) then
for _, frame in pairs(self.chatFrames) do
self:AddMouseOverHook(frame);
end
else
for _, frame in pairs(self.chatFrames) do
self:RemoveMouseOverHook(frame);
end
end
end
function LybrialChat:ValidateChatFrame(frame)
if ((not frame) or frame.isAdded) then
return false;
end
if (not frame:IsVisible()) then
return false;
end
return true;
end
function LybrialChat:AddChatFrame(frame, setParent)
if (not LybrialChat:ValidateChatFrame(frame)) then
return ;
end
self:AddMouseOverHook(frame);
frame.isAdded = true;
if (setParent) then
frame.setParent = true;
else
frame.setParent = false;
end
tinsert(self.chatFrames, frame);
end
function LybrialChat:AddMouseOverHook(frame)
if (not self:IsHooked(frame, "OnEnter")) then
self:HookScript(frame, "OnEnter", function()
LybrialChat.frame:SetMouseOverFade(true, LybrialChat.frame:IsShown(), true);
end);
end
if (not self:IsHooked(frame, "OnLeave")) then
self:HookScript(frame, "OnLeave", function()
LybrialChat.frame:SetMouseOverFade(true, LybrialChat.frame:IsShown(), false);
end);
end
end
function LybrialChat:RemoveMouseOverHook(frame)
if (self:IsHooked(frame, "OnEnter")) then
self:Unhook(frame, "OnEnter");
end
if (self:IsHooked(frame, "OnLeave")) then
self:Unhook(frame, "OnLeave");
end
end
function LybrialChat:GetChatFrames(elapsed)
LybrialChat.elapsed = (LybrialChat.elapsed + elapsed);
if (LybrialChat.elapsed >= LybrialChat.interval) then
if (InCombatLockdown() or C_PetBattles.IsInBattle()) then
return ;
end
for i = 1, NUM_CHAT_WINDOWS do
LybrialChat:AddChatFrame(_G["ChatFrame" .. i], true);
LybrialChat:AddChatFrame(_G["ChatFrame" .. i .. "Tab"], true);
LybrialChat:AddChatFrame(_G["ChatFrame" .. i].ScrollBar, false);
LybrialChat:AddChatFrame(_G["ChatFrame" .. i].ScrollToBottomButton, false);
LybrialChat:AddChatFrame(_G["ChatFrame" .. i].FontStringContainer, false);
LybrialChat:AddChatFrame(_G["ChatFrame" .. i].ResizeButton, false);
end
LybrialChat:OnUpdateChatFrames();
LybrialChat.elapsed = 0;
end
end
This is already working quite good. There are just two things bothering me.
1. If I mouse over a chat channel name, a player name or an item name in the chat the chat
fades out. This happens because the on leave event is getting triggered. That means
channel name, player name and item name are different frames. I cant manage to find
out what frames. I need to hook them up too like I did with all the other frames.
2. In combat log there the following frame:
- CombatLogQuickButtonFrame
- CombatLogQuickButtonFrameButtonFrame1
- CombatLogQuickButtonFrameButtonFrame2
Hooking these three frames like I did with the other frames does not lead to the expected
result. So I suspect I need to hook another frame which I also cant find.
Any Chat Expert who has an idea?