local A, L = ... if not L.C.emote.enable then return end -- 表情选择器框架 local EmoteTableFrame = CreateFrame("Frame", "EmoteTableFrame", UIParent, BackdropTemplateMixin and "BackdropTemplate" or nil) EmoteTableFrame:SetMovable(true) EmoteTableFrame:RegisterForDrag("LeftButton") EmoteTableFrame:SetScript("OnDragStart", EmoteTableFrame.StartMoving) EmoteTableFrame:SetScript("OnDragStop", EmoteTableFrame.StopMovingOrSizing) EmoteTableFrame:EnableMouse(true) EmoteTableFrame:SetWidth((L.C.emote.listsize + 6) * 12 + 10) EmoteTableFrame:SetHeight((L.C.emote.listsize + 6) * 5 + 10) EmoteTableFrame:SetPoint("BOTTOMRIGHT", ChatFrame1EditBox, "TOPRIGHT", 1, 5) EmoteTableFrame.backdrop = L.CreateBackdrop(EmoteTableFrame) -- EmoteTableFrame:SetBackdrop({ -- bgFile = "Interface\\Buttons\\WHITE8x8", -- edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", -- tile = true, -- tileSize = 16, -- edgeSize = 16, -- insets = {left = 3, right = 3, top = 3, bottom = 3} -- }) -- EmoteTableFrame:SetBackdropColor(0.05, 0.05, 0.05, 0.8) -- EmoteTableFrame:SetBackdropBorderColor(0.3, 0.3, 0.3) -- 表情选择框出现位置 默认30,30 EmoteTableFrame:Hide() EmoteTableFrame:SetFrameStrata("DIALOG") -- 表情解析规则 local fmtstring = format("\124T%%s:%d\124t", max(floor(select(2, SELECTED_CHAT_FRAME:GetFont())), L.C.emote.iconsize)) -- 自定义表情开始的序号 local customEmoteStartIndex = 9 local lang = GetLocale() local maps = {Angel="Angel",Angry="Angry",Biglaugh="Biglaugh",Clap="Clap",Cool="Cool",Cry="Cry",Cute="Cute",Despise="Despise",Dreamsmile="Dreamsmile",Embarras="Embarras",Evil="Evil",Excited="Excited",Faint="Faint",Fight="Fight",Flu="Flu",Freeze="Freeze",Frown="Frown",Greet="Greet",Grimace="Grimace",Growl="Growl",Happy="Happy",Heart="Heart",Horror="Horror",Ill="Ill",Innocent="Innocent",Kongfu="Kongfu",Love="Love",Mail="Mail",Makeup="Makeup",Mario="Mario",Meditate="Meditate",Miserable="Miserable",Okay="Okay",Pretty="Pretty",Puke="Puke",Shake="Shake",Shout="Shout",Silent="Silent",Shy="Shy",Sleep="Sleep",Smile="Smile",Suprise="Suprise",Surrender="Surrender",Sweat="Sweat",Tear="Tear",Tears="Tears",Think="Think",Titter="Titter",Ugly="Ugly",Victory="Victory",Volunteer="Volunteer",Wronged="Wronged"} if lang == "zhCN" then maps = {Angel="天使",Angry="生气",Biglaugh="大笑",Clap="鼓掌",Cool="酷",Cry="哭",Cute="可爱",Despise="鄙视",Dreamsmile="美梦",Embarras="尴尬",Evil="邪恶",Excited="兴奋",Faint="晕",Fight="打架",Flu="流感",Freeze="呆",Frown="皱眉",Greet="致敬",Grimace="鬼脸",Growl="龇牙",Happy="开心",Heart="心",Horror="恐惧",Ill="生病",Innocent="无辜",Kongfu="功夫",Love="花痴",Mail="邮件",Makeup="化妆",Mario="马里奥",Meditate="沉思",Miserable="可怜",Okay="好",Pretty="漂亮",Puke="吐",Shake="握手",Shout="喊",Silent="闭嘴",Shy="害羞",Sleep="睡觉",Smile="微笑",Suprise="吃惊",Surrender="失败",Sweat="流汗",Tear="流泪",Tears="悲剧",Think="想",Titter="偷笑",Ugly="猥琐",Victory="胜利",Volunteer="雷锋",Wronged="委屈"} elseif lang == "zhTW" then maps = {Angel="天使",Angry="生氣",Biglaugh="大笑",Clap="鼓掌",Cool="酷",Cry="哭",Cute="可愛",Despise="鄙視",Dreamsmile="美夢",Embarras="尷尬",Evil="邪惡",Excited="興奮",Faint="暈",Fight="打架",Flu="流感",Freeze="呆",Frown="皺眉",Greet="致敬",Grimace="鬼臉",Growl="齜牙",Happy="開心",Heart="心",Horror="恐懼",Ill="生病",Innocent="無辜",Kongfu="功夫",Love="花癡",Mail="郵件",Makeup="化妝",Mario="馬里奧",Meditate="沉思",Miserable="可憐",Okay="好",Pretty="漂亮",Puke="吐",Shake="握手",Shout="喊",Silent="閉嘴",Shy="害羞",Sleep="睡覺",Smile="微笑",Suprise="吃驚",Surrender="失敗",Sweat="流汗",Tear="流淚",Tears="悲劇",Think="想",Titter="偷笑",Ugly="猥瑣",Victory="勝利",Volunteer="雷鋒",Wronged="委屈"} end local emotes = { --原版暴雪提供的8个图标 {"{rt1}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_1]=]}, {"{rt2}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_2]=]}, {"{rt3}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_3]=]}, {"{rt4}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_4]=]}, {"{rt5}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_5]=]}, {"{rt6}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_6]=]}, {"{rt7}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_7]=]}, {"{rt8}", [=[Interface\TargetingFrame\UI-RaidTargetingIcon_8]=]}, } for i,v in pairs(maps) do local tex = L.C.mediapath .. "emotions\\" .. i local key = "{" .. v .. "}" table.insert(emotes, {key, tex}) end -- --自定义表情 -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Angel]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Angry]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Biglaugh]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Clap]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Cool]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Cry]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Cutie]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Despise]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Dreamsmile]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Embarrass]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Evil]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Excited]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Faint]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Fight]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Flu]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Freeze]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Frown]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Greet]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Grimace]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Growl]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Happy]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Heart]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Horror]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Ill]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Innocent]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Kongfu]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Love]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Mail]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Makeup]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Mario]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Meditate]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Miserable]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Okay]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Pretty]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Puke]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Shake]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Shout]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Shuuuu]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Shy]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Sleep]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Smile]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Suprise]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Surrender]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Sweat]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Tear]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Tears]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Think]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Titter]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Ugly]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Victory]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Volunteer]=]}, -- {"{"..maps[Angel].."}", [=[Interface\Addons\rChatPlus\medias\emotions\Wronged]=]} -- } local function ChatEmoteFilter(self, event, msg, ...) for i = customEmoteStartIndex, #emotes do if msg:find(emotes[i][1]) then msg = msg:gsub(emotes[i][1], format(fmtstring, emotes[i][2]), 1) end end return false, msg, ... end local function ToggleEmoteTable() if (EmoteTableFrame:IsShown()) then EmoteTableFrame:Hide() else EmoteTableFrame:Show() end end L.ToggleEmoteTable = ToggleEmoteTable local function EmoteIconMouseUp(frame, button) if (button == "LeftButton") then local chatFrame = GetCVar("chatStyle") == "im" and SELECTED_CHAT_FRAME or DEFAULT_CHAT_FRAME local eb = chatFrame and chatFrame.editBox if (eb) then eb:Insert(frame.text) eb:Show(); eb:SetFocus() end end ToggleEmoteTable() end local icon, row, col row = 1 col = 1 for i = 1, #emotes do text = emotes[i][1] texture = emotes[i][2] icon = CreateFrame("Frame", format("IconButton%d", i), EmoteTableFrame) icon:SetWidth(L.C.emote.listsize + 6) icon:SetHeight(L.C.emote.listsize + 6) icon.text = text icon.texture = icon:CreateTexture(nil, "ARTWORK") icon.texture:SetTexture(texture) icon.texture:SetAllPoints(icon) icon:Show() icon:SetPoint( "TOPLEFT", 5 + (col - 1) * (L.C.emote.listsize + 6), -5 - (row - 1) * (L.C.emote.listsize + 6) ) icon:SetScript("OnMouseUp", EmoteIconMouseUp) icon:EnableMouse(true) col = col + 1 if (col > 12) then row = row + 1 col = 1 end end ChatFrame_AddMessageEventFilter("CHAT_MSG_CHANNEL", ChatEmoteFilter)-- 公共频道 ChatFrame_AddMessageEventFilter("CHAT_MSG_SAY", ChatEmoteFilter)-- 说 ChatFrame_AddMessageEventFilter("CHAT_MSG_YELL", ChatEmoteFilter)-- 大喊 ChatFrame_AddMessageEventFilter("CHAT_MSG_RAID", ChatEmoteFilter)-- 团队 ChatFrame_AddMessageEventFilter("CHAT_MSG_RAID_LEADER", ChatEmoteFilter)-- 团队领袖 ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY", ChatEmoteFilter)-- 队伍 ChatFrame_AddMessageEventFilter("CHAT_MSG_PARTY_LEADER", ChatEmoteFilter)-- 队伍领袖 ChatFrame_AddMessageEventFilter("CHAT_MSG_GUILD", ChatEmoteFilter)-- 公会 ChatFrame_AddMessageEventFilter("CHAT_MSG_AFK", ChatEmoteFilter)-- AFK玩家自动回复 ChatFrame_AddMessageEventFilter("CHAT_MSG_DND", ChatEmoteFilter)-- 切勿打扰自动回复 -- 副本和副本领袖 ChatFrame_AddMessageEventFilter("CHAT_MSG_INSTANCE_CHAT", ChatEmoteFilter) ChatFrame_AddMessageEventFilter("CHAT_MSG_INSTANCE_CHAT_LEADER", ChatEmoteFilter) -- 解析战网私聊 ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", ChatEmoteFilter) ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_INFORM", ChatEmoteFilter) ChatFrame_AddMessageEventFilter("CHAT_MSG_BN_WHISPER", ChatEmoteFilter) ChatFrame_AddMessageEventFilter("CHAT_MSG_BN_WHISPER_INFORM", ChatEmoteFilter) -- 解析社区聊天内容 ChatFrame_AddMessageEventFilter("CHAT_MSG_COMMUNITIES_CHANNEL", ChatEmoteFilter)