From ebc20dfb1f6569d52245a09e4293b5b40f14ff87 Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 2 Jan 2018 12:41:28 +0100 Subject: [PATCH] bubbles: add chat bubble integration --- api/config.lua | 3 ++ modules/bubbles.lua | 72 +++++++++++++++++++++++++++++++++++++++++++++ modules/gui.lua | 3 ++ pfUI.toc | 1 + 4 files changed, 79 insertions(+) create mode 100644 modules/bubbles.lua diff --git a/api/config.lua b/api/config.lua index 16bd6538..4a66f79f 100644 --- a/api/config.lua +++ b/api/config.lua @@ -535,6 +535,9 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("chat", "global", "fadeout", "0") pfUI:UpdateConfig("chat", "global", "fadetime", "300") pfUI:UpdateConfig("chat", "global", "scrollspeed", "1") + pfUI:UpdateConfig("chat", "bubbles", "chat", "1") + pfUI:UpdateConfig("chat", "bubbles", "party", "1") + pfUI:UpdateConfig("chat", "bubbles", "alpha", ".75") pfUI:UpdateConfig("nameplates", nil, "use_unitfonts", "0") pfUI:UpdateConfig("nameplates", nil, "overlap", "0") diff --git a/modules/bubbles.lua b/modules/bubbles.lua new file mode 100644 index 00000000..860aa13d --- /dev/null +++ b/modules/bubbles.lua @@ -0,0 +1,72 @@ +pfUI:RegisterModule("bubbles", function () + + local alpha = tonumber(C.chat.bubbles.alpha) + + SetCVar("chatBubbles", tonumber(C.chat.bubbles.chat)) + SetCVar("chatBubblesParty", tonumber(C.chat.bubbles.party)) + + pfUI.bubbles = CreateFrame("Frame", "pfChatBubbles", UIParent) + pfUI.bubbles:RegisterEvent("CHAT_MSG_SAY") + pfUI.bubbles:RegisterEvent("CHAT_MSG_YELL") + pfUI.bubbles:RegisterEvent("CHAT_MSG_PARTY") + pfUI.bubbles:RegisterEvent("CHAT_MSG_PARTY_LEADER") + pfUI.bubbles:RegisterEvent("CHAT_MSG_MONSTER_SAY") + pfUI.bubbles:RegisterEvent("CHAT_MSG_MONSTER_YELL") + pfUI.bubbles:RegisterEvent("CHAT_MSG_MONSTER_PARTY") + + pfUI.bubbles:SetScript("OnEvent", function() + pfUI.bubbles:SetScript("OnUpdate", pfUI.bubbles.ScanBubbles) + end) + + function pfUI.bubbles:IsBubble(f) + if f:GetName() then return end + if not f:GetRegions() then return end + return f:GetRegions():GetTexture() == "Interface\\Tooltips\\ChatBubble-Background" + end + + function pfUI.bubbles:ScanBubbles() + local childs = { WorldFrame:GetChildren() } + for _, f in pairs(childs) do + if not f.frame and pfUI.bubbles:IsBubble(f) then + local textures = {f:GetRegions()} + for _, object in pairs(textures) do + if object:GetObjectType() == "Texture" then + object:SetTexture('') + elseif object:GetObjectType() == 'FontString' then + f.text = object + end + end + + f.frame = CreateFrame("Frame", nil, f) + f.frame:SetScale(UIParent:GetScale()) + f.frame:SetAllPoints(f) + + f.frame.text = f.frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") + f.frame.text:SetFont(pfUI.font_default, C.global.font_size, "OUTLINE") + f.frame.text:SetJustifyH("CENTER") + f.frame.text:SetJustifyV("CENTER") + f.frame.text:SetAllPoints(f.frame) + + CreateBackdrop(f.frame, nil, nil, alpha) + f.frame.backdrop:SetPoint("TOPLEFT", f, "TOPLEFT", 0, -10) + f.frame.backdrop:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 0, 10) + + f.text:Hide() + local r,g,b,a = f.text:GetTextColor() + f.frame.text:SetText(f.text:GetText()) + f.frame.text:SetTextColor(r,g,b,a) + f.frame.backdrop:SetBackdropBorderColor(r,g,b,a) + + f:SetScript("OnShow", function() + this.text:Hide() + local r,g,b,a = this.text:GetTextColor() + this.frame.text:SetText(this.text:GetText()) + this.frame.text:SetTextColor(r,g,b,a) + this.frame.backdrop:SetBackdropBorderColor(r,g,b,a) + end) + end + end + + pfUI.bubbles:SetScript("OnUpdate", nil) + end +end) diff --git a/modules/gui.lua b/modules/gui.lua index 21fb0a68..5746fcff 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1373,6 +1373,9 @@ pfUI:RegisterModule("gui", function () CreateConfig(this, T["Enable Chat Fade"], C.chat.global, "fadeout", "checkbox") CreateConfig(this, T["Seconds Before Chat Fade"], C.chat.global, "fadetime") CreateConfig(this, T["Mousewheel Scroll Speed"], C.chat.global, "scrollspeed") + CreateConfig(this, T["Enable Chat Bubbles"], C.chat.bubbles, "chat", "checkbox") + CreateConfig(this, T["Enable Party Chat Bubbles"], C.chat.bubbles, "party", "checkbox") + CreateConfig(this, T["Chat Bubble Transparency"], C.chat.bubbles, "alpha") this.setup = true end end) diff --git a/pfUI.toc b/pfUI.toc index 99430e46..8eb4e7fe 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -53,6 +53,7 @@ modules\actionbar.lua modules\hunterbar.lua modules\rangecheck.lua modules\chat.lua +modules\bubbles.lua modules\addons.lua modules\minimap.lua modules\panel.lua