Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

bChat Edit

By: a guest on Apr 24th, 2012  |  syntax: Lua  |  size: 10.40 KB  |  views: 333  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -----------------------------------------------
  2. --Config
  3. -----------------------------------------------
  4. -- Font Shadow
  5. shadowoffset = {x = 1, y = -1}
  6. -- Hide Black Combat Log Bar
  7. hidecombat = true
  8. -- Justify Combat Log to the Right, 0/1 = off/on
  9. combatlogright = 0
  10. -----------------------------------------------
  11. --Config End
  12. -----------------------------------------------
  13. for i = 1, NUM_CHAT_WINDOWS do
  14.      _G['ChatFrame'..i]:SetFont("Fonts\\FRIZQT__.ttf", 12, "OUTLINE")
  15. end
  16.  
  17. CHAT_FONT_HEIGHTS = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}
  18. ChatTypeInfo.WHISPER.sticky = 1
  19. ChatTypeInfo.OFFICER.sticky = 1
  20. ChatTypeInfo.CHANNEL.sticky = 1
  21.  
  22. ChatFrameMenuButton.Show = ChatFrameMenuButton.Hide
  23. ChatFrameMenuButton:Hide()
  24. FriendsMicroButton.Show = FriendsMicroButton.Hide
  25. FriendsMicroButton:Hide()
  26. BNToastFrame:SetClampedToScreen(true)
  27.  
  28.  
  29. _G.CHAT_WHISPER_INFORM_GET = 'To %s:\32'
  30. _G.CHAT_WHISPER_GET = 'From %s:\32'
  31. _G.CHAT_YELL_GET = '%s:\32'
  32. _G.CHAT_SAY_GET = '%s:\32'
  33. _G.CHAT_BATTLEGROUND_GET = '|Hchannel:Battleground|h[BG]|h %s:\32'
  34. _G.CHAT_BATTLEGROUND_LEADER_GET = '|Hchannel:Battleground|hBG|h %s:\32'
  35. _G.CHAT_GUILD_GET = '|Hchannel:Guild|h[G]|h %s:\32'
  36. _G.CHAT_PARTY_GET = '|Hchannel:Party|h[P]|h %s:\32'
  37. _G.CHAT_PARTY_LEADER_GET = '|Hchannel:party|h[P]|h %s:\32'
  38. _G.CHAT_PARTY_GUIDE_GET = '|Hchannel:PARTY|h[P]|h %s:\32'
  39. _G.CHAT_OFFICER_GET = '|Hchannel:o|h[O]|h %s:\32'
  40. _G.CHAT_RAID_GET = '|Hchannel:raid|h[R]|h %s:\32'
  41. _G.CHAT_RAID_LEADER_GET = '[|Hchannel:raid|hR|h] %s:\32'
  42. _G.CHAT_RAID_WARNING_GET = 'RW %s:\32'
  43.  
  44. CHAT_FRAME_FADE_OUT_TIME = 0
  45. CHAT_TAB_HIDE_DELAY = 1
  46. CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1
  47. CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = 0
  48. CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 1
  49. CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = 0
  50. CHAT_FRAME_TAB_ALERTING_MOUSEOVER_ALPHA = 1
  51. CHAT_FRAME_TAB_ALERTING_NOMOUSE_ALPHA = 0
  52.  
  53. if hidecombat==true then
  54.     local EventFrame = CreateFrame("Frame");
  55.     EventFrame:RegisterEvent("ADDON_LOADED");
  56.     local function EventHandler(self, event, ...)
  57.         if ... == "Blizzard_CombatLog" then
  58.             local topbar = _G["CombatLogQuickButtonFrame_Custom"];
  59.             if not topbar then return end
  60.             topbar:Hide();
  61.             topbar:HookScript("OnShow", function(self) topbar:Hide(); end);
  62.             topbar:SetHeight(0);
  63.         end
  64.     end
  65.     EventFrame:SetScript("OnEvent", EventHandler);
  66. end
  67.  
  68. local gsub = _G.string.gsub
  69. local newAddMsg = {}
  70. CHAT_FLAG_GM = "GM "
  71. CHAT_BN_WHISPER_INFORM_GET = "T: %s "
  72. CHAT_BN_WHISPER_GET = "F: %s "
  73. CHAT_RAID_WARNING_GET = "%s "
  74.  
  75. local function AddMessage(frame, text, ...)
  76.     text = gsub(text, "%[(%d0?)%. .-%]", "[%1]")
  77.     text = gsub(text, "^|Hchannel:[^%|]+|h%[[^%]]+%]|h ", "")
  78.         text = gsub(text, "|Hplayer:([^%|]+)|h%[([^%]]+)%]|h", "|Hplayer:%1|h%2|h")
  79.     text = gsub(text, "<Away>", "<AFK>")
  80.         text = gsub(text, "<Busy>", "<DND>")
  81.     text = gsub(text, "|Hplayer:([^%|]+)|h(.+)|h says:", "|Hplayer:%1|h%2|h:")
  82.         text = gsub(text, "|Hplayer:([^%|]+)|h(.+)|h yells:", "|Hplayer:%1|h%2|h:")
  83.         text = gsub(text, "|Hplayer:([^%|]+)|h(.+)|h whispers:", "F |Hplayer:%1|h%2|h:")
  84.         text = gsub(text, "^To ", "T ")
  85.     text = gsub(text, "Guild Message of the Day:", "GMotD -")
  86.     text = gsub(text, '([wWhH][wWtT][wWtT][%.pP]%S+[^%p%s])', '|cffffffff|Hurl:%1|h[%1]|h|r')
  87.     text = gsub(text, "%[%d+%. WorldDefense%]", "Defense ")
  88.     text = gsub(text, "%[%d+%. LocalDefense.-%]", "Local ")
  89.     text = gsub(text, "%[%d+%. LookingForGroup%]", "LFG ")
  90.     text = gsub(text, "%[%d+%. GuildRecruitment.-%]", "GRecruit ")
  91.     text = gsub(text, "Joined Channel:", "+")
  92.     text = gsub(text, "Left Channel:", "- ")
  93.     text = gsub(text, "Changed Channel:", ">")
  94.         text = gsub(text, "%[(%d0?)%. .-%]", "%1 ")
  95.         return newAddMsg[frame:GetName()](frame, text, ...)
  96. end
  97.  
  98. function string.color(text, color)
  99.     return "|cff"..color..text.."|r"
  100. end
  101. function string.link(text, type, value, color)
  102.     return "|H"..type..":"..tostring(value).."|h"..tostring(text):color(color or "ffffff").."|h"
  103. end
  104. local function highlighturl(before,url,after)
  105.     foundurl = true
  106.     return " "..string.link(""..url.."", "url", url, "DDDDDD").." "
  107. end
  108. local function searchforurl(frame, text, ...)
  109.     foundurl = false
  110.     if string.find(text, "%pTInterface%p+") then foundurl = true end
  111.     if not foundurl then text = string.gsub(text, "(%s?)(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?:%d%d?%d?%d?%d?)(%s?)", highlighturl) end
  112.     if not foundurl then text = string.gsub(text, "(%s?)(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?)(%s?)", highlighturl) end
  113.     if not foundurl then text = string.gsub(text, "(%s?)([%w_-]+%.?[%w_-]+%.[%w_-]+:%d%d%d?%d?%d?)(%s?)", highlighturl) end
  114.     if not foundurl then text = string.gsub(text, "(%s?)(%a+://[%w_/%.%?%%=~&-'%-]+)(%s?)", highlighturl) end
  115.     if not foundurl then text = string.gsub(text, "(%s?)(www%.[%w_/%.%?%%=~&-'%-]+)(%s?)", highlighturl) end
  116.     if not foundurl then text = string.gsub(text, "(%s?)([_%w-%.~-]+@[_%w-]+%.[_%w-%.]+)(%s?)", highlighturl) end
  117.     frame.am(frame,text,...)
  118. end--]]
  119.  
  120. local tabs = {"Left", "Middle", "Right", "SelectedLeft", "SelectedMiddle",
  121.     "SelectedRight", "Glow", "HighlightLeft", "HighlightMiddle",
  122.     "HighlightRight"}
  123.  
  124. for i = 1, NUM_CHAT_WINDOWS do
  125.     local cf = 'ChatFrame'..i
  126.     local tex = ({_G[cf..'EditBox']:GetRegions()})
  127.    
  128.     _G[cf..'ButtonFrame'].Show = _G[cf..'ButtonFrame'].Hide
  129.     _G[cf..'ButtonFrame']:Hide()
  130.    
  131.     _G[cf..'EditBox']:SetAltArrowKeyMode(false)
  132.     _G[cf..'EditBox']:ClearAllPoints()
  133.     _G[cf..'EditBox']:SetPoint('BOTTOMLEFT', ChatFrame1, 'TOPLEFT', 0, 6)
  134.     _G[cf..'EditBox']:SetPoint('TOPRIGHT', _G.ChatFrame1, 'TOPRIGHT', 0, 30)
  135.     _G[cf..'EditBox']:SetShadowOffset(0, 0)
  136.     _G[cf..'EditBox']:SetBackdrop({bgFile = 'Interface\\Buttons\\WHITE8x8', edgeFile = 'Interface\\Buttons\\WHITE8x8', edgeSize = 2})
  137.     _G[cf..'EditBox']:SetBackdropColor(0,0,0,.8)
  138.     _G[cf..'EditBox']:SetBackdropBorderColor(0,0,0,1)
  139.     _G[cf..'EditBox']:HookScript("OnEditFocusGained", function(self) self:Show() end)
  140.         _G[cf..'EditBox']:HookScript("OnEditFocusLost", function(self) self:Hide() end)
  141.     _G[cf..'EditBoxHeader']:SetShadowOffset(0, 0)
  142.    
  143.         _G["ChatFrame"..i.."Tab"]:HookScript("OnClick", function() _G["ChatFrame"..i.."EditBox"]:Hide() end)
  144.     tex[6]:SetAlpha(0) tex[7]:SetAlpha(0) tex[8]:SetAlpha(0) tex[9]:SetAlpha(0) tex[10]:SetAlpha(0) tex[11]:SetAlpha(0)
  145.     _G[cf]:SetMinResize(0,0)
  146.         _G[cf]:SetMaxResize(0,0)
  147.     _G[cf]:SetFading(true)     
  148.         _G[cf]:SetClampRectInsets(0,0,0,0)
  149.     _G[cf]:SetShadowOffset(shadowoffset.x, shadowoffset.y)
  150.     _G[cf..'ResizeButton']:SetPoint("BOTTOMRIGHT", cf, "BOTTOMRIGHT", 9,-5)
  151.     _G[cf..'ResizeButton']:SetScale(.4)
  152.     _G[cf..'ResizeButton']:SetAlpha(0.5)
  153.    
  154.     for g = 1, #CHAT_FRAME_TEXTURES do
  155.         _G["ChatFrame"..i..CHAT_FRAME_TEXTURES[g]]:SetTexture(nil)
  156.     end
  157.     for index, value in pairs(tabs) do
  158.         local texture = _G['ChatFrame'..i..'Tab'..value]
  159.         texture:SetTexture(nil)
  160.     end
  161.     if i ~= 2 then
  162.                 local f = _G[format("%s%d", "ChatFrame", i)]
  163.                 newAddMsg[format("%s%d", "ChatFrame", i)] = f.AddMessage
  164.                 f.AddMessage = AddMessage
  165.         end
  166.     if combatlogright == 1 then
  167.         if i == 2 then
  168.             _G[cf]:SetJustifyH("Right")
  169.         end
  170.     end
  171. end
  172.  
  173. local AltInvite = SetItemRef
  174. SetItemRef = function(link, text, button)
  175.     local linkType = string.sub(link, 1, 6)
  176.     if IsAltKeyDown() and linkType == "player" then
  177.         local name = string.match(link, "player:([^:]+)")
  178.         InviteUnit(name)
  179.         return nil
  180.     end
  181.     return AltInvite(link,text,button)
  182. end
  183.  
  184. FloatingChatFrame_OnMouseScroll = function(self, dir)
  185.     if(dir > 0) then
  186.         if(IsShiftKeyDown()) then
  187.             self:ScrollToTop() else self:ScrollUp() end
  188.     else if(IsShiftKeyDown()) then
  189.         self:ScrollToBottom() else self:ScrollDown() end
  190.     end
  191. end
  192.  
  193. local orig = ChatFrame_OnHyperlinkShow
  194.         function ChatFrame_OnHyperlinkShow(frame, link, text, button)
  195.                 local type, value = link:match("(%a+):(.+)")
  196.                 curlink = value
  197.                 if ( type == "url" ) then
  198.                         StaticPopup_Show("TEXT_COPY_POPUP")
  199.                                 else
  200.                         orig(self, link, text, button)
  201.                 end
  202.         end
  203.        
  204.         -- URL Copy (in rChat by zork)
  205.         local foundurl = false
  206.  
  207.         function string.color(text, color)
  208.                 return "|cff".."0099FF"..text.."|r"
  209.         end
  210.  
  211.         function string.link(text, type, value, color)
  212.                 return "|H"..type..":"..tostring(value).."|h"..tostring(text):color(color or "ffffff").."|h"
  213.         end
  214.  
  215.         local function highlighturl(before,url,after)
  216.                 foundurl = true
  217.                 return " "..string.link("["..url.."]", "url", url, color).." "
  218.         end
  219.  
  220.         local function searchforurl(frame, text, ...)
  221.  
  222.                 foundurl = false
  223.  
  224.                 if string.find(text, "%pTInterface%p+") then
  225.                         foundurl = true
  226.                 end
  227.                 if not foundurl then
  228.                         text = string.gsub(text, "(%s?)(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?:%d%d?%d?%d?%d?)(%s?)", highlighturl)
  229.                 end    
  230.                 if not foundurl then
  231.                         text = string.gsub(text, "(%s?)(%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?)(%s?)", highlighturl)
  232.                 end
  233.                 if not foundurl then
  234.                         text = string.gsub(text, "(%s?)([%w_-]+%.?[%w_-]+%.[%w_-]+:%d%d%d?%d?%d?)(%s?)", highlighturl)
  235.                 end
  236.                 if not foundurl then
  237.                         text = string.gsub(text, "(%s?)(%a+://[%w_/%.%?%%=~&-'%-]+)(%s?)", highlighturl)
  238.                 end
  239.                 if not foundurl then
  240.                         text = string.gsub(text, "(%s?)(www%.[%w_/%.%?%%=~&-'%-]+)(%s?)", highlighturl)
  241.                 end
  242.                 if not foundurl then
  243.                 text = string.gsub(text, "(%s?)([_%w-%.~-]+@[_%w-]+%.[_%w-%.]+)(%s?)", highlighturl)
  244.                 end
  245.  
  246.                 frame.am(frame,text,...)
  247.         end
  248.        
  249.         StaticPopupDialogs["TEXT_COPY_POPUP"] = {
  250.                 text = "URL Copy",
  251.                 button2 = TEXT(CLOSE),
  252.                 hasEditBox = 1,
  253.                 hasWideEditBox = 1,
  254.                 OnShow = function(self)
  255.                         local eB = _G[self:GetName().."EditBox"]
  256.                         eB:SetText(curlink)
  257.                         curlink = nil
  258.                         eB:SetFocus()
  259.                         eB:HighlightText(0)
  260.                         local bt = _G[self:GetName().."Button2"]
  261.                         bt:ClearAllPoints()
  262.                         bt:SetWidth(200)
  263.                         bt:SetHeight(25)
  264.                         bt:SetPoint("CENTER", eB, "CENTER", 0, -30)
  265.                 end,
  266.                 timeout = 60,
  267.                 whileDead = true,
  268.                 EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end,
  269.                 hideOnEscape = true,
  270.         }
  271.          
  272.         -- local orig = ChatFrame_OnHyperlinkShow
  273.         -- function ChatFrame_OnHyperlinkShow(frame, link, text, button)
  274.                 -- local type, value = link:match("(%a+):(.+)")
  275.                 -- curlink = value
  276.                 -- if ( type == "url" ) then
  277.                         -- StaticPopup_Show("TEXT_COPY_POPUP")         
  278.                         -- orig(self, link, text, button)
  279.                 -- end
  280.         -- end 
  281.         -- URL Copy -- END