mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-30 03:06:01 +00:00
chat: add url detection and copy dialog
This commit is contained in:
+2
-1
@@ -170,6 +170,7 @@ function pfUI:LoadConfig()
|
||||
pfUI:UpdateConfig("chat", "text", "timeformat", "%H:%M:%S")
|
||||
pfUI:UpdateConfig("chat", "text", "timebracket", "[]")
|
||||
pfUI:UpdateConfig("chat", "text", "timecolor", ".8,.8,.8,1")
|
||||
pfUI:UpdateConfig("chat", "text", "detecturl", "1")
|
||||
pfUI:UpdateConfig("chat", "text", "classcolor", "1")
|
||||
pfUI:UpdateConfig("chat", "left", "width", "380")
|
||||
pfUI:UpdateConfig("chat", "left", "height", "180")
|
||||
@@ -177,7 +178,7 @@ function pfUI:LoadConfig()
|
||||
pfUI:UpdateConfig("chat", "right", "alwaysshow", "0")
|
||||
pfUI:UpdateConfig("chat", "right", "width", "380")
|
||||
pfUI:UpdateConfig("chat", "right", "height", "180")
|
||||
pfUI:UpdateConfig("chat", "global", "tabdock", "1")
|
||||
pfUI:UpdateConfig("chat", "global", "tabdock", "1")
|
||||
pfUI:UpdateConfig("chat", "global", "custombg", "0")
|
||||
pfUI:UpdateConfig("chat", "global", "background", ".2,.2,.2,.5")
|
||||
pfUI:UpdateConfig("chat", "global", "border", ".4,.4,.4,.5")
|
||||
|
||||
@@ -45,6 +45,73 @@ pfUI:RegisterModule("chat", function ()
|
||||
CreateBackdrop(pfUI.chat.left.panelTop, default_border, nil, .8)
|
||||
end
|
||||
|
||||
-- url copy dialog
|
||||
function pfUI.chat:FormatLink(link)
|
||||
return " |cffccccff|Hurl:" .. link .. "|h[" .. link .. "]|h|r "
|
||||
end
|
||||
|
||||
pfUI.chat.urlcopy = CreateFrame("Frame", "pfURLCopy", UIParent)
|
||||
pfUI.chat.urlcopy:Hide()
|
||||
pfUI.chat.urlcopy:SetWidth(270)
|
||||
pfUI.chat.urlcopy:SetHeight(65)
|
||||
pfUI.chat.urlcopy:SetPoint("CENTER", 0, 0)
|
||||
CreateBackdrop(pfUI.chat.urlcopy, nil, nil, 0.8)
|
||||
|
||||
pfUI.chat.urlcopy:SetMovable(true)
|
||||
pfUI.chat.urlcopy:EnableMouse(true)
|
||||
pfUI.chat.urlcopy:SetScript("OnMouseDown",function()
|
||||
this:StartMoving()
|
||||
end)
|
||||
|
||||
pfUI.chat.urlcopy:SetScript("OnMouseUp",function()
|
||||
this:StopMovingOrSizing()
|
||||
end)
|
||||
|
||||
pfUI.chat.urlcopy:SetScript("OnShow", function()
|
||||
this.text:HighlightText()
|
||||
end)
|
||||
|
||||
pfUI.chat.urlcopy.text = CreateFrame("EditBox", "pfURLCopyEditBox", pfUI.chat.urlcopy)
|
||||
pfUI.chat.urlcopy.text:SetTextColor(.2,1,.8,1)
|
||||
pfUI.chat.urlcopy.text:SetJustifyH("CENTER")
|
||||
|
||||
pfUI.chat.urlcopy.text:SetWidth(250)
|
||||
pfUI.chat.urlcopy.text:SetHeight(20)
|
||||
pfUI.chat.urlcopy.text:SetPoint("TOP", pfUI.chat.urlcopy, "TOP", 0, -10)
|
||||
pfUI.chat.urlcopy.text:SetFontObject(GameFontNormal)
|
||||
CreateBackdrop(pfUI.chat.urlcopy.text)
|
||||
|
||||
pfUI.chat.urlcopy.text:SetScript("OnEscapePressed", function(self)
|
||||
pfUI.chat.urlcopy:Hide()
|
||||
end)
|
||||
|
||||
pfUI.chat.urlcopy.text:SetScript("OnEditFocusLost", function(self)
|
||||
pfUI.chat.urlcopy:Hide()
|
||||
end)
|
||||
|
||||
pfUI.chat.urlcopy.close = CreateFrame("Button", "pfURLCopyClose", pfUI.chat.urlcopy, "UIPanelButtonTemplate")
|
||||
pfUI.api.SkinButton(pfUI.chat.urlcopy.close)
|
||||
pfUI.chat.urlcopy.close:SetWidth(70)
|
||||
pfUI.chat.urlcopy.close:SetHeight(18)
|
||||
pfUI.chat.urlcopy.close:SetPoint("BOTTOMRIGHT", pfUI.chat.urlcopy, "BOTTOMRIGHT", -10, 10)
|
||||
|
||||
pfUI.chat.urlcopy.close:SetText("Close")
|
||||
pfUI.chat.urlcopy.close:SetScript("OnClick", function()
|
||||
pfUI.chat.urlcopy:Hide()
|
||||
end)
|
||||
|
||||
pfUI.chat.urlcopy.SetItemRef = SetItemRef
|
||||
|
||||
function _G.SetItemRef (link, text, button)
|
||||
if (strsub(link, 1, 3) == "url") then
|
||||
if string.len(link) > 4 and string.sub(link,1,4) == "url:" then
|
||||
pfUI.chat.urlcopy.text:SetText(string.sub(link,5, string.len(link)))
|
||||
pfUI.chat.urlcopy:Show()
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- whisper forwarding
|
||||
pfUI.chat.left.panelTop.proxy = CreateFrame("Button", "leftChatWhisperProxy", pfUI.chat.left.panelTop)
|
||||
pfUI.chat.left.panelTop.proxy:RegisterEvent("CHAT_MSG_WHISPER")
|
||||
@@ -595,6 +662,16 @@ pfUI:RegisterModule("chat", function ()
|
||||
_G["ChatFrame"..i].AddMessage = function (frame, text, ...)
|
||||
if text then
|
||||
|
||||
if C.chat.text.detecturl == "1" then
|
||||
text = string.gsub (text, " www%.([_A-Za-z0-9-]+)%.(%S+)%s?", pfUI.chat:FormatLink("www.%1.%2"))
|
||||
text = string.gsub (text, " (%a+)://(%S+)%s?", pfUI.chat:FormatLink("%1://%2"))
|
||||
text = string.gsub (text, " ([_A-Za-z0-9-%.]+)@([_A-Za-z0-9-]+)(%.+)([_A-Za-z0-9-%.]+)%s?", pfUI.chat:FormatLink("%1@%2%3%4"))
|
||||
text = string.gsub (text, " (%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?):(%d%d?%d?%d?%d?)%s?", pfUI.chat:FormatLink("%1.%2.%3.%4:%5"))
|
||||
text = string.gsub (text, " (%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%s?", pfUI.chat:FormatLink("%1.%2.%3.%4"))
|
||||
text = string.gsub (text, " ([_A-Za-z0-9-]+)%.([_A-Za-z0-9-]+)%.(%S+)%s?", pfUI.chat:FormatLink("%1.%2.%3"))
|
||||
text = string.gsub (text, " ([_A-Za-z0-9-]+)%.([_A-Za-z0-9-]+)%.(%S+)%:([_0-9-]+)%s?", pfUI.chat:FormatLink("%1.%2.%3:%4"))
|
||||
end
|
||||
|
||||
if C.chat.text.classcolor == "1" then
|
||||
local Name = string.gsub(text, ".*|Hplayer:(.-)|h.*", "%1")
|
||||
if pfUI_playerDB[Name] and pfUI_playerDB[Name].class ~= nil then
|
||||
|
||||
@@ -983,6 +983,7 @@ pfUI:RegisterModule("gui", function ()
|
||||
pfUI.gui:CreateConfig(pfUI.gui.chat, "Timestamp Format", C.chat.text, "timeformat")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.chat, "Timestamp Brackets", C.chat.text, "timebracket")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.chat, "Timestamp Color", C.chat.text, "timecolor", "color")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.chat, "Enable URL Detection", C.chat.text, "detecturl", "checkbox")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.chat, "Enable Class Colors", C.chat.text, "classcolor", "checkbox")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.chat, "Left Chat Width", C.chat.left, "width")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.chat, "Left Chat Height", C.chat.left, "height")
|
||||
|
||||
@@ -94,6 +94,7 @@ pfUI:RegisterModule("thirdparty", function ()
|
||||
pfUIhookWIM:RegisterEvent("ADDON_LOADED")
|
||||
pfUIhookWIM:SetScript("OnEvent", function()
|
||||
if not pfUIhookWIM_PostMessage and WIM_PostMessage then
|
||||
_G.WIM_isLinkURL = function() return false end
|
||||
pfUIhookWIM_PostMessage = _G.WIM_PostMessage
|
||||
_G.WIM_PostMessage = function(user, msg, ttype, from, raw_msg)
|
||||
pfUIhookWIM_PostMessage(user, msg, ttype, from, raw_msg)
|
||||
|
||||
Reference in New Issue
Block a user