if not BarbolUI["chatt"].enable == true then return end
local Chat = CreateFrame("Frame")
local tabalpha = 1
local tabnoalpha = 0
local _G = _G
local origs = {}
local type = type
hidecombat = false
local FONT = "Interface\\AddOns\\textures\\Prototype.ttf"
function UIScale()
if BarbolUI["General"].autoscaleUI == true then
BarbolUI["General"].uiscale = min(2, max(.64, 768/string.match(({GetScreenResolutions()})[GetCurrentResolution()], "%d+x(%d+)")))
end
end
UIScale()
-- pixel perfect script of custom ui scale.
local mult = 768/string.match(GetCVar("gxResolution"), "%d+x(%d+)")/BarbolUI["General"].uiscale
local function scale(x)
return mult*math.floor(x/mult+.5)
end
function Scale(x) return scale(x) end
mult = mult
function CreatePanel(f, w, h, a1, p, a2, x, y)
local _, class = UnitClass("player")
local r, g, b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b
sh = Scale(h)
sw = Scale(w)
f:SetFrameLevel(1)
f:SetHeight(sh)
f:SetWidth(sw)
f:SetFrameStrata("BACKGROUND")
f:SetPoint(a1, p, a2, x, y)
f:SetBackdrop({
bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
edgeFile = "Interface\\Buttons\\WHITE8x8",
tile = false, tileSize = 0, edgeSize = mult,
insets = { left = -mult, right = -mult, top = -mult, bottom = -mult}
})
f:SetBackdropColor(.05,.05,.05,0)
f:SetBackdropBorderColor(.15,.15,.15,0)
end
Anchorchatbgdummy = CreateFrame("Frame","Move_chatbgdummy",UIParent)
Anchorchatbgdummy:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 20, 36)
local chatbgdummy = CreateFrame("Frame", "ChatBackground", UIParent)
CreatePanel(chatbgdummy, 376, 120, "BOTTOMLEFT", Anchorchatbgdummy)
local function Kill(object)
if object.UnregisterAllEvents then
object:UnregisterAllEvents()
end
object.Show = dummy
object:Hide()
end
for i = 1, 10 do
local x=({_G["ChatFrame"..i.."EditBox"]:GetRegions()})
x[9]:SetAlpha(0)
x[10]:SetAlpha(0)
x[11]:SetAlpha(0)
end
for i = 1, NUM_CHAT_WINDOWS do
if ( i ~= 2 ) then
local f = _G["ChatFrame"..i]
local am = f.AddMessage
f.AddMessage = function(frame, text, ...)
return am(frame, text:gsub('|h%[(%d+)%. .-%]|h', '|h[%1]|h'), ...)
end
end
end
_G.CHAT_BATTLEGROUND_GET = "|Hchannel:Battleground|h".."[BG]".."|h %s:\32"
_G.CHAT_BATTLEGROUND_LEADER_GET = "|Hchannel:Battleground|h".."[BG]".."|h %s:\32"
_G.CHAT_BN_WHISPER_INFORM_GET = "T: %s "
_G.CHAT_BN_WHISPER_GET = "F: %s "
_G.CHAT_GUILD_GET = "|Hchannel:Guild|h".."[G]".."|h %s:\32"
_G.CHAT_OFFICER_GET = "|Hchannel:o|h".."[O]".."|h %s:\32"
_G.CHAT_PARTY_GET = "|Hchannel:Party|h".."[P]".."|h %s:\32"
_G.CHAT_PARTY_GUIDE_GET = "|Hchannel:party|h".."[P]".."|h %s:\32"
_G.CHAT_PARTY_LEADER_GET = "|Hchannel:party|h".."[P]".."|h %s:\32"
_G.CHAT_RAID_GET = "|Hchannel:raid|h".."[R]".."|h %s:\32"
_G.CHAT_RAID_LEADER_GET = "|Hchannel:raid|h".."[R]".."|h %s:\32"
_G.CHAT_RAID_WARNING_GET = "[W]".." %s:\32"
_G.CHAT_SAY_GET = "%s:\32"
_G.CHAT_WHISPER_GET = "Fr".." %s:\32"
_G.CHAT_WHISPER_INFORM_GET = "To %s "
_G.CHAT_YELL_GET = "%s:\32"
_G.CHAT_FLAG_AFK = "|cffFF0000".."[AFK]".."|r "
_G.CHAT_FLAG_DND = "|cffE7E716".."[DND]".."|r "
_G.CHAT_FLAG_GM = "|cff4154F5".."[GM]".."|r "
_G.ERR_FRIEND_ONLINE_SS = "|Hplayer:%s|h[%s]|h ".."is now |cff298F00online|r".."!"
_G.ERR_FRIEND_OFFLINE_S = "%s ".."is now |cffff0000offline|r".."!"
Kill(FriendsMicroButton)
Kill(ChatFrameMenuButton)
if hidecombat==true then
local EventFrame = CreateFrame("Frame");
EventFrame:RegisterEvent("ADDON_LOADED");
local function EventHandler(self, event, ...)
if ... == "Blizzard_CombatLog" then
local topbar = _G["CombatLogQuickButtonFrame_Custom"];
if not topbar then return end
topbar:Hide();
topbar:HookScript("OnShow", function(self) topbar:Hide(); end);
topbar:SetHeight(0);
end
end
EventFrame:SetScript("OnEvent", EventHandler);
end
local function SetChatStyle(frame)
local id = frame:GetID()
local chat = frame:GetName()
local tab = _G[chat.."Tab"]
tab:SetAlpha(1)
tab.SetAlpha = UIFrameFadeRemoveFrame
_G[chat]:SetFading(false)
_G[chat.."TabText"]:SetTextColor(unpack(BarbolUI["Colors"].Border))
_G[chat.."TabText"].SetTextColor = dummy
_G[chat.."TabText"]:SetFont(FONT,10,"OUTLINE")
_G[chat]:SetClampRectInsets(0,0,0,0)
_G[chat]:SetClampedToScreen(false)
_G[chat]:SetMinResize(371,111)
for j = 1, #CHAT_FRAME_TEXTURES do
_G[chat..CHAT_FRAME_TEXTURES[j]]:SetTexture(nil)
end
Kill(_G[format("ChatFrame%sTabLeft", id)])
Kill(_G[format("ChatFrame%sTabMiddle", id)])
Kill(_G[format("ChatFrame%sTabRight", id)])
Kill(_G[format("ChatFrame%sTabSelectedLeft", id)])
Kill(_G[format("ChatFrame%sTabSelectedMiddle", id)])
Kill(_G[format("ChatFrame%sTabSelectedRight", id)])
Kill(_G[format("ChatFrame%sTabHighlightLeft", id)])
Kill(_G[format("ChatFrame%sTabHighlightMiddle", id)])
Kill(_G[format("ChatFrame%sTabHighlightRight", id)])
Kill(_G[format("ChatFrame%sTabSelectedLeft", id)])
Kill(_G[format("ChatFrame%sTabSelectedMiddle", id)])
Kill(_G[format("ChatFrame%sTabSelectedRight", id)])
tab.leftSelectedTexture:Hide()
tab.middleSelectedTexture:Hide()
tab.rightSelectedTexture:Hide()
tab.leftSelectedTexture.Show = tab.leftSelectedTexture.Hide
tab.middleSelectedTexture.Show = tab.middleSelectedTexture.Hide
tab.rightSelectedTexture.Show = tab.rightSelectedTexture.Hide
Kill(_G[format("ChatFrame%sButtonFrameUpButton", id)])
Kill(_G[format("ChatFrame%sButtonFrameDownButton", id)])
Kill(_G[format("ChatFrame%sButtonFrameBottomButton", id)])
Kill(_G[format("ChatFrame%sButtonFrameMinimizeButton", id)])
Kill(_G[format("ChatFrame%sButtonFrame", id)])
Kill(_G[format("ChatFrame%sEditBoxFocusLeft", id)])
Kill(_G[format("ChatFrame%sEditBoxFocusMid", id)])
Kill(_G[format("ChatFrame%sEditBoxFocusRight", id)])
local a, b, c = select(6, _G[chat.."EditBox"]:GetRegions()); Kill (a); Kill (b); Kill (c)
_G[chat.."EditBox"]:SetAltArrowKeyMode(false)
_G[chat.."EditBox"]:Hide()
_G[chat.."EditBox"]:HookScript("OnEditFocusLost", function(self) self:Hide() end)
_G[chat.."Tab"]:HookScript("OnClick", function() _G[chat.."EditBox"]:Hide() end)
local editbox = _G["ChatFrame"..id.."EditBox"]
local left, mid, right = select(6, editbox:GetRegions())
left:Hide(); mid:Hide(); right:Hide()
editbox:ClearAllPoints();
editbox:SetPoint("BOTTOMLEFT", UIParent, 20, 156)
editbox:SetWidth(BarbolUI["chatt"].editboxwidth)
editbox:SetHeight(BarbolUI["chatt"].editboxheight)
end
local function SetupChat(self)
for i = 1, NUM_CHAT_WINDOWS do
local frame = _G[format("ChatFrame%s", i)]
SetChatStyle(frame)
FCFTab_UpdateAlpha(frame)
end
ChatTypeInfo.WHISPER.sticky = 1
ChatTypeInfo.BN_WHISPER.sticky = 1
ChatTypeInfo.OFFICER.sticky = 1
ChatTypeInfo.RAID_WARNING.sticky = 1
ChatTypeInfo.CHANNEL.sticky = 1
end
local function SetupChatPosAndFont(self)
for i = 1, NUM_CHAT_WINDOWS do
local chat = _G[format("ChatFrame%s", i)]
local tab = _G[format("ChatFrame%sTab", i)]
local id = chat:GetID()
local name = FCF_GetChatWindowInfo(id)
local point = GetChatWindowSavedPosition(id)
local _, fontSize = FCF_GetChatWindowInfo(id)
FCF_SetChatWindowFontSize(nil, chat, 12)
ChatFrame1:ClearAllPoints()
ChatFrame1:SetPoint("BOTTOMLEFT", ChatBackground, "BOTTOMLEFT", 3, 5)
end
end
Chat:RegisterEvent("ADDON_LOADED")
Chat:RegisterEvent("PLAYER_ENTERING_WORLD")
Chat:SetScript("OnEvent", function(self, event, ...)
for i = 1, NUM_CHAT_WINDOWS do
_G["ChatFrame"..i]:SetClampRectInsets(0,0,0,0)
_G["ChatFrame"..i]:SetWidth(BarbolUI["chatt"].chatframewidth)
_G["ChatFrame"..i]:SetHeight(BarbolUI["chatt"].chatframeheight)
end
local addon = ...
if event == "ADDON_LOADED" then
if addon == "Blizzard_CombatLog" then
self:UnregisterEvent("ADDON_LOADED")
SetupChat(self)
end
elseif event == "PLAYER_ENTERING_WORLD" then
SetupChatPosAndFont(self)
Chat:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
if event == "PLAYER_LOGIN" then
SetupChatPosAndFont(self)
end
end)
local function SetupTempChat()
local frame = FCF_GetCurrentChatFrame()
SetChatStyle(frame)
end
hooksecurefunc("FCF_OpenTemporaryWindow", SetupTempChat)
for i = 1, NUM_CHAT_WINDOWS do
local editBox = _G["ChatFrame"..i.."EditBox"]
editBox:HookScript("OnTextChanged", function(self)
local text = self:GetText()
if text:len() < 5 then
if text:sub(1, 4) == "/tt " then
local unitname, realm
unitname, realm = UnitName("target")
if unitname then unitname = gsub(unitname, " ", "") end
if unitname and not UnitIsSameServer("player", "target") then
unitname = unitname .. "-" .. gsub(realm, " ", "")
end
ChatFrame_SendTell((unitname or "Invalid Target"), ChatFrame1)
end
end
end)
end
local SetItemRef_orig = SetItemRef
function ReURL_SetItemRef(link, text, button, chatFrame)
if (strsub(link, 1, 3) == "url") then
local ChatFrameEditBox = ChatEdit_ChooseBoxForSend()
local url = strsub(link, 5);
if (not ChatFrameEditBox:IsShown()) then
ChatEdit_ActivateChat(ChatFrameEditBox)
end
ChatFrameEditBox:Insert(url)
ChatFrameEditBox:HighlightText()
else
SetItemRef_orig(link, text, button, chatFrame)
end
end
SetItemRef = ReURL_SetItemRef
function ReURL_AddLinkSyntax(chatstring)
if (type(chatstring) == "string") then
local extraspace;
if (not strfind(chatstring, "^ ")) then
extraspace = true;
chatstring = " "..chatstring;
end
chatstring = gsub (chatstring, " www%.([_A-Za-z0-9-]+)%.(%S+)%s?", ReURL_Link("www.%1.%2"))
chatstring = gsub (chatstring, " (%a+)://(%S+)%s?", ReURL_Link("%1://%2"))
chatstring = gsub (chatstring, " ([_A-Za-z0-9-%.]+)@([_A-Za-z0-9-]+)(%.+)([_A-Za-z0-9-%.]+)%s?", ReURL_Link("%1@%2%3%4"))
chatstring = gsub (chatstring, " (%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?):(%d%d?%d?%d?%d?)%s?", ReURL_Link("%1.%2.%3.%4:%5"))
chatstring = gsub (chatstring, " (%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%s?", ReURL_Link("%1.%2.%3.%4"))
if (extraspace) then
chatstring = strsub(chatstring, 2);
end
end
return chatstring
end
REURL_COLOR = "16FF5D"
ReURL_Brackets = false
ReUR_CustomColor = true
function ReURL_Link(url)
if (ReUR_CustomColor) then
if (ReURL_Brackets) then
url = " |cff"..REURL_COLOR.."|Hurl:"..url.."|h["..url.."]|h|r "
else
url = " |cff"..REURL_COLOR.."|Hurl:"..url.."|h"..url.."|h|r "
end
else
if (ReURL_Brackets) then
url = " |Hurl:"..url.."|h["..url.."]|h "
else
url = " |Hurl:"..url.."|h"..url.."|h "
end
end
return url
end
for i=1, NUM_CHAT_WINDOWS do
local frame = getglobal("ChatFrame"..i)
local addmessage = frame.AddMessage
frame.AddMessage = function(self, text, ...) addmessage(self, ReURL_AddLinkSyntax(text), ...) end
end
-----------------------------------------------------------------------------
-- Copy Chat (by Shestak)
-----------------------------------------------------------------------------
local lines = {}
local frame = nil
local editBox = nil
local isf = nil
local function CreatCopyFrame()
frame = CreateFrame("Frame", "CopyFrame", UIParent)
frame:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
edgeFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
tile = 0, tileSize = 0, edgeSize = 1,
insets = { left = -1, right = -1, top = -1, bottom = -1 }
})
local tex = frame:CreateTexture(nil, "BORDER")
tex:SetPoint("TOPLEFT", frame, "TOPLEFT", 2, -2)
tex:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 2)
tex:SetVertexColor(.05,.05,.05,0)
tex:SetDrawLayer("BORDER", -8)
frame.tex = tex
frame:SetBackdropColor(.05,.05,.05,.7)
frame:SetBackdropBorderColor(.15,.15,.15,0)
frame:SetWidth(500)
frame:SetHeight(300)
frame:SetScale(0.9)
frame:SetPoint("LEFT", UIParent, "LEFT", 10, 0)
frame:Hide()
frame:SetFrameStrata("DIALOG")
local scrollArea = CreateFrame("ScrollFrame", "CopyScroll", frame, "UIPanelScrollFrameTemplate")
scrollArea:SetPoint("TOPLEFT", frame, "TOPLEFT", 8, -30)
scrollArea:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -30, 8)
editBox = CreateFrame("EditBox", "CopyBox", frame)
editBox:SetMultiLine(true)
editBox:SetMaxLetters(99999)
editBox:EnableMouse(true)
editBox:SetAutoFocus(false)
editBox:SetFontObject(ChatFontNormal)
editBox:SetWidth(500)
editBox:SetHeight(300)
editBox:SetScript("OnEscapePressed", function() frame:Hide() end)
scrollArea:SetScrollChild(editBox)
local close = CreateFrame("Button", "CopyCloseButton", frame, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", frame, "TOPRIGHT",0, 0)
isf = true
end
local function GetLines(...)
local ct = 1
for i = select("#", ...), 1, -1 do
local region = select(i, ...)
if region:GetObjectType() == "FontString" then
lines[ct] = tostring(region:GetText())
ct = ct + 1
end
end
return ct - 1
end
local function Copy(cf)
local _, size = cf:GetFont()
FCF_SetChatWindowFontSize(cf, cf, 0.01)
local lineCt = GetLines(cf:GetRegions())
local text = table.concat(lines, "\n", 1, lineCt)
FCF_SetChatWindowFontSize(cf, cf, size)
if not isf then CreatCopyFrame() end
frame:Show()
editBox:SetText(text)
editBox:HighlightText(1)
end
function ChatCopyButtons()
for i = 1, NUM_CHAT_WINDOWS do
local cf = _G[format("ChatFrame%d", i)]
local button = CreateFrame("Button", format("ButtonCF%d", i), cf)
button:SetHeight(20)
button:SetWidth(20)
button:SetPoint("TOPRIGHT", cf, "TOPRIGHT", 0 , 0)
local buttontext = button:CreateFontString(nil,"OVERLAY",nil)
buttontext:SetFont(FONT,10,"OUTLINE")
buttontext:SetText("C")
buttontext:SetPoint("CENTER", 1, 0)
buttontext:SetJustifyH("CENTER")
buttontext:SetJustifyV("CENTER")
buttontext:SetTextColor(unpack(BarbolUI["Colors"].Border))
button:SetScript("OnMouseUp", function(self, btn)
if i == 1 and btn == "RightButton" then
ToggleFrame(ChatMenu)
else
Copy(cf)
end
end)
end
end
ChatCopyButtons()
------------------------------------------------------------------------
-- Enhance/rewrite a Blizzard feature, chatframe mousewheel.
------------------------------------------------------------------------
local ScrollLines = 3 -- set the jump when a scroll is done !
function FloatingChatFrame_OnMouseScroll(self, delta)
if delta < 0 then
if IsShiftKeyDown() then
self:ScrollToBottom()
else
for i = 1, ScrollLines do
self:ScrollDown()
end
end
elseif delta > 0 then
if IsShiftKeyDown() then
self:ScrollToTop()
else
for i = 1, ScrollLines do
self:ScrollUp()
end
end
end
end