diff --git a/Modules/ChatEngine.lua b/Modules/ChatEngine.lua index 7cfd0db..693127e 100644 --- a/Modules/ChatEngine.lua +++ b/Modules/ChatEngine.lua @@ -100,10 +100,10 @@ db_defaults.chat = { showAlerts = true, }, battleground = { - + }, say = { - + }, bn = { showAlerts = true, @@ -117,7 +117,7 @@ local function getRuleSet() local curState = db.pop_rules.chat.alwaysOther and "other" or curState return db.pop_rules.chat[curState]; end - + local function createWidget_Chat() local button = _G.CreateFrame("Button"); @@ -154,7 +154,7 @@ local function createWidget_Chat() button:SetScript("OnLeave", function(self) --ChatUserList:Hide(); end); - + return button; end @@ -174,7 +174,7 @@ local function getChatWindow(ChatName, chatType) Windows[ChatName]:UpdateIcon(); Windows[ChatName].widgets.chat_info:SetActive(true); Windows[ChatName].chatList = Windows[ChatName].chatList or {}; - + if(chatType == "guild") then Windows[ChatName].CHAT_listCount = _G.GetNumGuildMembers; Windows[ChatName].CHAT_listFun = _G.GetGuildRosterInfo; @@ -182,7 +182,7 @@ local function getChatWindow(ChatName, chatType) Windows[ChatName].CHAT_listCount = nil; Windows[ChatName].CHAT_listFun = nil; end - + return Windows[ChatName]; end end @@ -274,7 +274,7 @@ function Guild:GUILD_ROSTER_UPDATE() -- update guild count cleanChatList(self.guildWindow); local count = 0; - for i=1, _G.GetNumGuildMembers() do + for i=1, _G.GetNumGuildMembers() do local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPoints, achievementRank, isMobile = _G.GetGuildRosterInfo(i); if(online) then --_G.GuildControlSetRank(rankIndex); @@ -371,7 +371,7 @@ function Officer:GUILD_ROSTER_UPDATE() -- update guild count cleanChatList(self.officerWindow); local count = 0; - for i=1, _G.GetNumGuildMembers() do + for i=1, _G.GetNumGuildMembers() do local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPoints, achievementRank, isMobile = _G.GetGuildRosterInfo(i); if(online) then --_G.GuildControlSetRank(rankIndex); @@ -605,7 +605,7 @@ function Raid:GROUP_ROSTER_UPDATE() end end self.raidWindow.widgets.chat_info:SetText(count); - end + end end function Raid:CHAT_MSG_RAID_CONTROLLER(eventController, ...) @@ -855,11 +855,15 @@ _G.LibStub:GetLibrary("LibChatHandler-1.0"):Embed(Say); function Say:OnEnable() RegisterWidget("chat_info", createWidget_Chat); - self:RegisterChatEvent("CHAT_MSG_SAY"); + self:RegisterChatEvent("CHAT_MSG_SAY"); + self:RegisterChatEvent("CHAT_MSG_EMOTE"); + self:RegisterChatEvent("CHAT_MSG_TEXT_EMOTE"); end function Say:OnDisable() - self:UnregisterChatEvent("CHAT_MSG_SAY"); + self:UnregisterChatEvent("CHAT_MSG_SAY"); + self:UnregisterChatEvent("CHAT_MSG_EMOTE"); + self:UnregisterChatEvent("CHAT_MSG_TEXT_EMOTE"); end function Say:OnWindowDestroyed(self) @@ -913,6 +917,76 @@ function Say:CHAT_MSG_SAY(...) end end +function Say:CHAT_MSG_EMOTE_CONTROLLER(eventController, ...) + if(eventController.ignoredByWIM or not db.chat.say.showEmotes) then + eventController:BlockFromDelegate(self); + return; + end + if(not db.chat.say.neverSuppress and getRuleSet().supress) then + eventController:BlockFromChatFrame(self); + end +end +Say.CHAT_MSG_TEXT_EMOTE_CONTROLLER = Say.CHAT_MSG_EMOTE_CONTROLLER + +function Say:CHAT_MSG_EMOTE(...) + local filter, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12 = honorChatFrameEventFilter("CHAT_MSG_EMOTE", ...); + if(filter) then + return; + end + arg2 = _G.Ambiguate(arg2, "none") + local win = getChatWindow(_G.SAY, "say"); + local color = _G.ChatTypeInfo["EMOTE"] or _G.NORMAL_FONT_COLOR; + self.chatLoaded = true; + arg3 = CleanLanguageArg(arg3); + --Don't handle say messages during encounters, when boss mods are handling them + local fightingBoss = _G.IsEncounterInProgress() or DBM and DBM:InCombat() or false + if not fightingBoss then + win:AddEventMessage(color.r, color.g, color.b, "CHAT_MSG_EMOTE", arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); + end + if(arg2 ~= _G.UnitName("player")) then + win.unreadCount = win.unreadCount and (win.unreadCount + 1) or 1; + if(not db.chat.say.neverPop) then + win:Pop("in"); + end + else + if(not db.chat.say.neverPop) then + win:Pop("out"); + end + end + if not fightingBoss then + CallModuleFunction("PostEvent_ChatMessage", "CHAT_MSG_EMOTE", arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); + end +end + +function Say:CHAT_MSG_TEXT_EMOTE(...) + local filter, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12 = honorChatFrameEventFilter("CHAT_MSG_EMOTE", ...); + if(filter) then + return; + end + arg2 = _G.Ambiguate(arg2, "none") + local win = getChatWindow(_G.SAY, "say"); + local color = _G.ChatTypeInfo["EMOTE"] or _G.NORMAL_FONT_COLOR; + self.chatLoaded = true; + arg3 = CleanLanguageArg(arg3); + --Don't handle say messages during encounters, when boss mods are handling them + local fightingBoss = _G.IsEncounterInProgress() or DBM and DBM:InCombat() or false + if not fightingBoss then + win:AddEventMessage(color.r, color.g, color.b, "CHAT_MSG_TEXT_EMOTE", arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); + end + if(arg2 ~= _G.UnitName("player")) then + win.unreadCount = win.unreadCount and (win.unreadCount + 1) or 1; + if(not db.chat.say.neverPop) then + win:Pop("in"); + end + else + if(not db.chat.say.neverPop) then + win:Pop("out"); + end + end + if not fightingBoss then + CallModuleFunction("PostEvent_ChatMessage", "CHAT_MSG_TEXT_EMOTE", arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); + end +end -------------------------------------- -- Channel Chat -- @@ -1146,7 +1220,7 @@ function ChatAlerts:PostEvent_ChatMessage(event, ...) elseif(event == "SAY" and db.chat.say.showAlerts) then win = getChatWindow(_G.SAY, "say"); end - + if(win and not win:IsVisible() and win.unreadCount and win.unreadCount > 0) then local chat_type = win.chatType == "battleground" and "INSTANCE_CHAT" or string.upper(win.chatType); local color = _G.ChatTypeInfo[chat_type] or _G.NORMAL_FONT_COLOR; -- Drii: ticket 344 color error if party/instance chat handled by WIM @@ -1165,9 +1239,9 @@ ChatAlerts:Enable(); -- create ChatOptions Module local ChatOptions = CreateModule("ChatOptions"); local function loadChatOptions() - + local desc = L["WIM will manage this chat type within its own message windows."]; - + -- standard chat template local function createChatTemplate(chatName, moduleName, chatType) local chatDB = db.chat[chatType]; @@ -1175,14 +1249,18 @@ local function loadChatOptions() f.sub = f:CreateSection(chatName, desc); f.sub.nextOffSetY = -10; f.sub:CreateCheckButton(L["Enable"], WIM.modules[moduleName], "enabled", nil, function(self, button) EnableModule(moduleName, self:GetChecked()); end); - f.sub.nextOffSetY = -30; + f.sub.nextOffSetY = -30; f.sub:CreateCheckButton(L["Show Minimap Alerts"], chatDB, "showAlerts"); - f.sub.nextOffSetY = -25; + f.sub.nextOffSetY = -25; + if chatType == 'say' then + f.sub.nextOffSetY = -25; + f.sub:CreateCheckButton(L["Include emotes."], chatDB, "showEmotes"); + end f.sub:CreateCheckButton(L["Never pop-up on my screen."], chatDB, "neverPop"); f.sub:CreateCheckButton(L["Never suppress messages."], chatDB, "neverSuppress"); return f; end - + local channelList = {}; local function getChannelList(world) --clear list @@ -1197,8 +1275,8 @@ local function loadChatOptions() end return channelList; end - - + + local channelScrollCount = 1; local function createChannelChatTemplate(chatName, channelType, channelListFun) local f = options.CreateOptionsFrame(); @@ -1206,7 +1284,7 @@ local function loadChatOptions() f.sub.nextOffSetY = -10; f.sub.enabled = f.sub:CreateCheckButton(L["Enable"], db.chat[channelType], "enabled", nil, function(self, button) Channel:SettingsChanged(); end); f.sub.nextOffSetY = -10; - + --list f.sub.list = f.sub:ImportCustomObject(_G.CreateFrame("Frame")); options.AddFramedBackdrop(f.sub.list); @@ -1265,13 +1343,13 @@ local function loadChatOptions() button.bg:SetColorTexture(1,1,1, ((#self.buttons+1) % 2)*.1); button.bg:SetGradientAlpha("HORIZONTAL", 1,1,1,1, 0,0,0,0); button.border = {}; - + button.border.left = button:CreateTexture(nil, "OVERLAY"); button.border.left:SetPoint("TOPLEFT"); button.border.left:SetPoint("BOTTOMLEFT"); button.border.left:SetWidth(4); button.border.left:SetColorTexture(1,1,1,.5); - + button.title = button:CreateFontString(nil, "OVERLAY", "ChatFontNormal"); button.title:SetPoint("TOPLEFT", 35, -8); button.title:SetPoint("TOPRIGHT"); @@ -1295,7 +1373,7 @@ local function loadChatOptions() local name = self:GetParent().channelName; db.chat[channelType].channelSettings[name].monitor = self:GetChecked(); end); - + -- Never Pop button.neverPop = _G.CreateFrame("CheckButton", nil, button, "UICheckButtonTemplate"); button.neverPop:SetPoint("TOPLEFT", button.cb1, "BOTTOMRIGHT", 20, 0); @@ -1333,8 +1411,8 @@ local function loadChatOptions() button.neverSuppress:SetScript("OnLeave", function(self) self:GetParent():GetParent().help:SetText(""); end); - - + + -- Show Minimap Alerts button.showAlerts = _G.CreateFrame("CheckButton", nil, button, "UICheckButtonTemplate"); button.showAlerts:SetPoint("TOPLEFT", button.neverPop, "TOPRIGHT", 150, 0); @@ -1353,7 +1431,7 @@ local function loadChatOptions() button.showAlerts:SetScript("OnLeave", function(self) self:GetParent():GetParent().help:SetText(""); end); - + -- Don't record history button.noHistory = _G.CreateFrame("CheckButton", nil, button, "UICheckButtonTemplate"); button.noHistory:SetPoint("TOPLEFT", button.showAlerts, "BOTTOMLEFT", 0, 0); @@ -1372,8 +1450,8 @@ local function loadChatOptions() button.noHistory:SetScript("OnLeave", function(self) self:GetParent():GetParent().help:SetText(""); end); - - + + -- Don't play sounds button.noSound = _G.CreateFrame("CheckButton", nil, button, "UICheckButtonTemplate"); button.noSound:SetPoint("TOPLEFT", button.noHistory, "TOPRIGHT", 100, 0); @@ -1392,9 +1470,9 @@ local function loadChatOptions() button.noSound:SetScript("OnLeave", function(self) self:GetParent():GetParent().help:SetText(""); end); - - - + + + if(#self.buttons == 0) then button:SetPoint("TOPLEFT"); button:SetPoint("TOPRIGHT", -25, 0); @@ -1402,7 +1480,7 @@ local function loadChatOptions() button:SetPoint("TOPLEFT", self.buttons[#self.buttons], "BOTTOMLEFT"); button:SetPoint("TOPRIGHT", self.buttons[#self.buttons], "BOTTOMRIGHT"); end - + button:SetScript("OnUpdate", function(self, elapsed) for _, border in pairs(self.border) do if(_G.MouseIsOver(self)) then @@ -1412,7 +1490,7 @@ local function loadChatOptions() end end end); - + table.insert(self.buttons, button); end for i=1, 4 do @@ -1425,51 +1503,51 @@ local function loadChatOptions() f.sub.list.help:SetJustifyH("LEFT"); local font, height, flags = f.sub.list.help:GetFont(); f.sub.list.help:SetFont(font, 12, flags); - - + + return f; end - + local function createGuildChat() local f = createChatTemplate(_G.GUILD, "GuildChat", "guild"); return f; end - + local function createOfficerChat() local f = createChatTemplate(_G.GUILD_RANK1_DESC, "OfficerChat", "officer"); return f; end - + local function createPartyChat() local f = createChatTemplate(_G.PARTY, "PartyChat", "party"); return f; end - + local function createRaidChat() local f = createChatTemplate(_G.RAID, "RaidChat", "raid"); return f; end - + local function createBattlegroundChat() local f = createChatTemplate(_G.INSTANCE_CHAT, "BattlegroundChat", "battleground"); return f; end - + local function createSayChat() local f = createChatTemplate(_G.SAY, "SayChat", "say"); return f; end - + local function createWorldChat() local f = createChannelChatTemplate(L["World Chat"], "world", function() return getChannelList(true); end); return f; end - + local function createCustomChat() local f = createChannelChatTemplate(L["Custom Chat"], "custom", getChannelList); return f; end - + RegisterOptionFrame(L["Chat"], _G.GUILD, createGuildChat); RegisterOptionFrame(L["Chat"], _G.GUILD_RANK1_DESC, createOfficerChat); RegisterOptionFrame(L["Chat"], _G.PARTY, createPartyChat); @@ -1478,7 +1556,7 @@ local function loadChatOptions() RegisterOptionFrame(L["Chat"], _G.SAY, createSayChat); RegisterOptionFrame(L["Chat"], L["World Chat"], createWorldChat); RegisterOptionFrame(L["Chat"], L["Custom Chat"], createCustomChat); - + dPrint("Chat Options Initialized..."); ChatOptions.optionsLoaded = true; end @@ -1491,8 +1569,8 @@ local function createUserList() win:SetPoint("CENTER"); -- set backdrop win:SetBackdrop({bgFile = "Interface\\AddOns\\"..addonTocName.."\\Modules\\Textures\\Menu_bg", - edgeFile = "Interface\\AddOns\\"..addonTocName.."\\Modules\\Textures\\Menu", - tile = true, tileSize = 32, edgeSize = 32, + edgeFile = "Interface\\AddOns\\"..addonTocName.."\\Modules\\Textures\\Menu", + tile = true, tileSize = 32, edgeSize = 32, insets = { left = 32, right = 32, top = 32, bottom = 32 }}); win:SetWidth(200); win.title = _G.CreateFrame("Frame", win:GetName().."Title", win); @@ -1508,7 +1586,7 @@ local function createUserList() win.title.text:SetJustifyH("RIGHT"); win.title.text:SetText("Testing..."); win.buttons = {}; - + for i = 1, USERLIST_BUTTON_COUNT do local button = _G.CreateFrame("Button", win:GetName().."Button1", win); button:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestLogTitleHighlight", "ADD"); @@ -1522,14 +1600,14 @@ local function createUserList() self.user = user; self.text:SetText(" "..user); end - + button:SetScript("OnClick", function(self, button) --if(button == "RightButton") then --_G.ChannelRosterFrame_ShowDropdown(self.user); --end end); - - + + if(i == 1) then button:SetPoint("TOPLEFT", 20, -35); button:SetPoint("RIGHT", -30, 0); @@ -1537,18 +1615,18 @@ local function createUserList() button:SetPoint("TOPLEFT", win.buttons[i-1], "BOTTOMLEFT"); button:SetPoint("TOPRIGHT", win.buttons[i-1], "BOTTOMRIGHT"); end - - table.insert(win.buttons, button); + + table.insert(win.buttons, button); end win:SetHeight(#win.buttons*win.buttons[1]:GetHeight() + 35 + 20); win.scroll = _G.CreateFrame("ScrollFrame", win:GetName().."Scroll", win, "FauxScrollFrameTemplate"); win.scroll:SetPoint("TOPLEFT", win.buttons[1], "TOPLEFT", 0, 0); win.scroll:SetPoint("BOTTOMRIGHT", win.buttons[#win.buttons], "BOTTOMRIGHT", -10, 0); - + win.scroll:SetScript("OnVerticalScroll", function(self, offset) _G.FauxScrollFrame_OnVerticalScroll(self, offset, win.buttons[1]:GetHeight(), win.updateList); end); - + win:SetScript("OnHide", function(self) self:Hide(); self.attachedTo = nil; @@ -1556,7 +1634,7 @@ local function createUserList() self.listFun = nil; self:SetParent(_G.UIParent); end); - + win:SetScript("OnUpdate", function(self, elapsed) if(_G.MouseIsOver(self) or (self.attachedTo and _G.MouseIsOver(self.attachedTo))) then self.idleTime = 0; @@ -1567,12 +1645,12 @@ local function createUserList() end end end); - - + + win.SetChannel = function(self, title) self.title.text:SetText(string.format(L["Users in %s"], title or _G.CHAT).." "); end - + win.PopUp = function(self, attachTo, point, point2, offsetX, offsetY) if(self.attachedTo == attachTo) then self:Hide(); @@ -1585,7 +1663,7 @@ local function createUserList() self:Show(); win:updateList(); end - + win.updateList = function(self) self = win; if(self.listCount and self.listFun) then @@ -1601,13 +1679,13 @@ local function createUserList() self.buttons[i]:Hide(); end end - + _G.FauxScrollFrame_Update(win.scroll, count, USERLIST_BUTTON_COUNT, self.buttons[1]:GetHeight()); else self:Hide(); end end - + win.SetParentWindow = function(self, parent, start) start = start or self; start.parentWindow = parent; @@ -1617,7 +1695,7 @@ local function createUserList() end end end - + return win; end @@ -1629,7 +1707,7 @@ end function ChatOptions:OnEnableWIM() loadChatOptions(); --load joined channels. - + --create user List if(not ChatUserList) then ChatUserList = createUserList(); diff --git a/Sources/WindowHandler.lua b/Sources/WindowHandler.lua index 88a1bbf..84144ea 100644 --- a/Sources/WindowHandler.lua +++ b/Sources/WindowHandler.lua @@ -2059,7 +2059,12 @@ RegisterMessageFormatting(L["Default"], function(smf, event, ...) event == "CHAT_MSG_RAID" or event == "CHAT_MSG_RAID_LEADER" or event == "CHAT_MSG_SAY" or event == "CHAT_MSG_PARTY_LEADER" or event == "CHAT_MSG_CHANNEL" or event == "CHAT_MSG_INSTANCE_CHAT" or event == "CHAT_MSG_INSTANCE_CHAT_LEADER") then return applyBracket().."|Hplayer:"..arg2..":"..arg11.."|h"..(db.coloredNames and doColoredNames(event, ...) or arg2).."|h"..applyBracket(2)..": "..arg1; - elseif(event == "CHAT_MSG_RAID_WARNING") then + elseif(event == "CHAT_MSG_EMOTE") then + return "|Hplayer:"..arg2..":"..arg11.."|h"..(db.coloredNames and doColoredNames(event, ...) or arg2).."|h".." "..arg1; + elseif(event == "CHAT_MSG_TEXT_EMOTE") then + local user = "|Hplayer:"..arg2..":"..arg11.."|h"..(db.coloredNames and doColoredNames(event, ...) or arg2).."|h" + return arg1; + elseif(event == "CHAT_MSG_RAID_WARNING") then return _G.RAID_WARNING.." "..applyBracket().."|Hplayer:"..arg2..":"..arg11.."|h"..(db.coloredNames and doColoredNames(event, ...) or arg2).."|h"..applyBracket(2)..": "..arg1; elseif(event == "CHAT_MSG_CHANNEL_JOIN") then return string.format(_G.CHAT_CHANNEL_JOIN_GET, arg2);