SHARE
TWEET

tChat

a guest Oct 7th, 2018 14 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -------------
  2. --Init Work--
  3. -------------
  4. ChatFontNormal:SetFont('Interface\\AddOns\\tChat\\Font.ttf', 12)
  5. local tabTexturesHideTable = {'Left','Middle','Right','SelectedLeft','SelectedRight','SelectedMiddle','HighlightLeft','HighlightMiddle','HighlightRight'}
  6. local chatFrameTexturesHideTable = {'ButtonFrame', 'LeftTexture', 'BottomLeftTexture', 'BottomTexture', 'BottomRightTexture', 'RightTexture', 'TopRightTexture', 'TopTexture', 'TopLeftTexture', 'Background'}
  7. local chatElementHideTable = {}
  8. table.insert(chatElementHideTable, ChatFrameMenuButton)
  9. table.insert(chatElementHideTable, ChatFrameChannelButton)
  10. table.insert(chatElementHideTable, QuickJoinToastButton)
  11. table.insert(chatElementHideTable, ChatFrameToggleVoiceDeafenButton)
  12. table.insert(chatElementHideTable, ChatFrameToggleVoiceMuteButton)
  13.  
  14. CHAT_FRAME_FADE_TIME = 0
  15. CHAT_TAB_SHOW_DELAY = 0
  16. CHAT_TAB_HIDE_DELAY = 0.5
  17. CHAT_FRAME_FADE_OUT_TIME = 1
  18. CHAT_FRAME_TAB_NORMAL_MOUSEOVER_ALPHA = 1
  19. CHAT_FRAME_TAB_NORMAL_NOMOUSE_ALPHA = 0
  20. CHAT_FRAME_TAB_SELECTED_MOUSEOVER_ALPHA = 1
  21. CHAT_FRAME_TAB_SELECTED_NOMOUSE_ALPHA = 0
  22.  
  23. for k, v in pairs(chatElementHideTable) do
  24.     v:Hide()
  25.     hooksecurefunc(v, 'Show', function()
  26.         if v:IsShown() then
  27.             v:Hide()
  28.         end
  29.     end)
  30. end
  31. ---------------------------
  32. --Handle the BNToastFrame--
  33. ---------------------------
  34. hooksecurefunc(BNToastFrame, 'Show', function()
  35.     BNToastFrame:SetBackdrop({
  36.         bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
  37.         edgeFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
  38.         edgeSize = 0.8,
  39.         insets = {
  40.             left = 0.8,
  41.             right = 0.8,
  42.             bottom = 0.8,
  43.             top = 0.8
  44.         }
  45.     })
  46.     BNToastFrame:SetBackdropColor(0.2, 0.2, 0.2, 1)
  47.     BNToastFrame:SetBackdropBorderColor(0, 0, 0, 1)
  48.     BNToastFrame:ClearAllPoints()
  49.     BNToastFrame:SetPoint('BOTTOMLEFT', ChatFrame1, 'TOPLEFT', 0, 72)
  50.  
  51.     BNToastFrame.CloseButton:SetNormalTexture('')
  52.     BNToastFrame.CloseButton:SetHighlightTexture('')
  53.     BNToastFrame.CloseButton:SetPushedTexture('')
  54.     BNToastFrame.CloseButton:SetDisabledTexture('')
  55.  
  56.     BNToastFrame.CloseButton.Text = BNToastFrame.CloseButton:CreateFontString(nil, 'OVERLAY')
  57.     BNToastFrame.CloseButton.Text:SetFont('Interface\\AddOns\\tChat\\Font.ttf', 14)
  58.     BNToastFrame.CloseButton.Text:SetPoint('CENTER', 5, 4)
  59.     BNToastFrame.CloseButton.Text:SetText('x')
  60.     BNToastFrame.CloseButton.Text:SetTextColor(0.5, 0.5, 0.5, 1)
  61. end)
  62.  
  63. BNToastFrame.CloseButton:HookScript('OnEnter', function()
  64.     BNToastFrame.CloseButton.Text:SetTextColor(0.41, 0.8, 0.94, 1)
  65. end)
  66.  
  67. BNToastFrame.CloseButton:HookScript('OnLeave', function()
  68.     BNToastFrame.CloseButton.Text:SetTextColor(0.5, 0.5, 0.5, 1)
  69. end)
  70.  
  71. hooksecurefunc(BNToastFrame, 'SetPoint', function()
  72.     local a, b, c, d, e = BNToastFrame:GetPoint()
  73.     if (a ~= 'BOTTOMLEFT' or c ~= 'TOPLEFT' or d ~= 0 or e ~= 72) then
  74.         BNToastFrame:SetPoint('BOTTOMLEFT', ChatFrame1, 'TOPLEFT', 0, 72)
  75.     end
  76. end)
  77. -----------------------------------------------------------------------
  78. --The main function which will move, resize, and make stuff less ugly--
  79. -----------------------------------------------------------------------
  80. local function tChatMain(frame)
  81.     local name = frame:GetName()
  82.     --make it so you can move the chat anywhere and resize it
  83.     _G[name]:SetClampRectInsets(0, 0, 0, 0)
  84.     _G[name]:SetMinResize(20, 20)
  85.     --hide all the stupid shit
  86.     for k, v in pairs(chatFrameTexturesHideTable) do
  87.         _G[name..v]:Hide()
  88.     end
  89.  
  90.     --hide the scroll bar and scrollbar thumb and make sure we never see the scroll bar again
  91.     _G[name].ScrollBar:Hide()
  92.     hooksecurefunc(_G[name].ScrollBar, 'Show', function(self)
  93.         if self:IsShown() then
  94.             self:Hide()
  95.         end
  96.     end)
  97.     _G[name..'ThumbTexture']:Hide()
  98.  
  99.     --move the resize button and make it smaller
  100.     local resizeButton = name..'ResizeButton'
  101.     _G[resizeButton]:SetScale(0.7)
  102.     _G[resizeButton]:SetPoint('BOTTOMRIGHT', _G[name], 'BOTTOMRIGHT', 0, 0)
  103.  
  104.     --move the scroll to the bottom button, and change its appearance, also hook in some stuff
  105.     local button = _G[name].ScrollToBottomButton
  106.     button:SetSize(10, 10)
  107.     button:ClearAllPoints()
  108.     if name == 'ChatFrame2' then
  109.         button:SetPoint('TOPLEFT', _G[name], 'TOPRIGHT', 2, 24)
  110.     else
  111.         button:SetPoint('TOPLEFT', _G[name], 'TOPRIGHT', 2, 0)
  112.     end
  113.     button:SetNormalTexture('')
  114.     button:SetHighlightTexture('')
  115.     button:SetPushedTexture('')
  116.     button.Flash:SetTexture('')
  117.     button.Text = _G[name].ScrollToBottomButton:CreateFontString(nil, 'OVERLAY')
  118.     button.Text:SetFont('Interface\\AddOns\\tChat\\Font.ttf', 12)
  119.     button.Text:SetPoint('TOPLEFT')
  120.     button.Text:SetText('V')
  121.     button.Text:SetTextColor(0.5, 0.5, 0.5, 1)
  122.     button:HookScript('OnClick', function()
  123.         _G[name].ScrollToBottomButton.Text:SetTextColor(0.5, 0.5, 0.5, 1)
  124.     end)
  125.  
  126.     --some of our tab modifications, mainly appearance; other mods are done outside of our for loop
  127.     local tab = name..'Tab'
  128.     if name == 'ChatFrame1' then
  129.         _G[tab]:ClearAllPoints()
  130.         _G[tab]:SetPoint('BOTTOMLEFT', ChatFrame1, 'TOPLEFT', 0, 32)
  131.     end
  132.     for key, value in pairs(tabTexturesHideTable) do
  133.         _G[tab..value]:SetTexture(nil)
  134.     end
  135.  
  136.     local tabText = tab..'Text'
  137.     _G[tabText]:SetFont('Interface\\AddOns\\tChat\\Font.ttf', 12)
  138.     _G[tabText]:SetTextColor(1, 1, 1, 1)
  139.     hooksecurefunc(_G[tabText], 'SetTextColor', function(self)
  140.         local a, b, c = self:GetTextColor()
  141.         if (a < 0.99 or b < 0.99 or c < 0.99) then
  142.             self:SetTextColor(1, 1, 1)
  143.         end
  144.     end)
  145.  
  146.     --our editbox modifications
  147.     local editbox = _G[name..'EditBox']
  148.     local tex = {editbox:GetRegions()}
  149.     editbox:SetAltArrowKeyMode(false)
  150.     _G[editbox:GetName()..'Left']:Hide()
  151.     _G[editbox:GetName()..'Mid']:Hide()
  152.     _G[editbox:GetName()..'Right']:Hide()
  153.  
  154.     for t = 6, #tex do
  155.         tex[t]:SetAlpha(0)
  156.     end
  157.  
  158.     editbox:ClearAllPoints()
  159.     editbox:SetPoint('BOTTOMLEFT', name, 'TOPLEFT', 0, 0)
  160.     editbox:SetPoint('BOTTOMRIGHT', name, 'TOPRIGHT', 0, 0)
  161. end
  162. ---------------------------
  163. --Rest of our tab changes--
  164. ---------------------------
  165. hooksecurefunc(_G['ChatFrame1Tab'], 'SetPoint', function(self) --don't need to hook other tabs, since they're all based on this one
  166.     local a, b, c, d, e = self:GetPoint()
  167.     if (a ~= 'BOTTOMLEFT' or c ~= 'TOPLEFT' or d ~= 0 or e ~= 32) then
  168.         self:ClearAllPoints()
  169.         self:SetPoint('BOTTOMLEFT', ChatFrame1, 'TOPLEFT', 0, 32)
  170.     end
  171. end)
  172.  
  173. hooksecurefunc('FCFTab_UpdateColors', function(self, selected)
  174.     if self:GetName() then
  175.         if selected then
  176.             _G[self:GetName()..'Text']:SetAlpha(1)
  177.         else
  178.             _G[self:GetName()..'Text']:SetAlpha(0.5)
  179.         end
  180.     end
  181. end)
  182. ----------------------------------------------------------
  183. --Hook section for things that don't want to simply hide--
  184. ----------------------------------------------------------
  185. hooksecurefunc('FCF_FadeInScrollbar', function(chatFrame)
  186.     if UIFrameIsFlashing(chatFrame.ScrollToBottomButton.Flash) then
  187.         chatFrame.ScrollToBottomButton.Text:SetTextColor(0.41, 0.8, 0.94, 1)
  188.     end
  189.     UIFrameFadeIn(chatFrame.ScrollToBottomButton, 0.1, chatFrame.ScrollToBottomButton:GetAlpha(), 1)
  190. end)
  191.  
  192. hooksecurefunc('FCF_FadeOutScrollbar', function(chatFrame)
  193.     if not UIFrameIsFlashing(chatFrame.ScrollToBottomButton.Flash) then
  194.         chatFrame.ScrollToBottomButton.Text:SetTextColor(0.5, 0.5, 0.5, 1)
  195.         UIFrameFadeOut(chatFrame.ScrollToBottomButton, 1, chatFrame.ScrollToBottomButton:GetAlpha(), 0)
  196.     end
  197. end)
  198. ----------------------------------------------------------------------------------------------
  199. --This is so our cool V scrolltobottombutton will update in real time when we reach the bottom
  200. ----------------------------------------------------------------------------------------------
  201. hooksecurefunc('ChatFrame_OnUpdate', function(self, elapsed)
  202.     local flash = self.ScrollToBottomButton.Flash
  203.     if flash then
  204.         local shouldFlash = not self:AtBottom()
  205.         if shouldFlash ~= UIFrameIsFlashing(flash) then
  206.             if not shouldFlash then
  207.                 self.ScrollToBottomButton.Text:SetTextColor(0.5, 0.5, 0.5, 1)
  208.             end
  209.         end
  210.     end
  211. end)
  212.  
  213. ------------------------------------------
  214. --Skin the ChatFrames to be good looking--
  215. ------------------------------------------
  216. local tChatBG = CreateFrame('frame', nil, UIParent)
  217. tChatBG:SetPoint('TOPLEFT', ChatFrame1, 'TOPLEFT', 0, 32)
  218. tChatBG:SetPoint('BOTTOMRIGHT', ChatFrame1, 'BOTTOMRIGHT', 0, 0)
  219. tChatBG:SetBackdrop({
  220.     bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
  221.     edgeFile = [=[Interface\ChatFrame\ChatFrameBackground]=],
  222.     edgeSize = -0.8,
  223.     insets = {
  224.         left = -0.8,
  225.         right = -0.8,
  226.         bottom = -0.8,
  227.         top = -0.8
  228.     }
  229. })
  230. tChatBG:SetBackdropColor(0.2, 0.2, 0.2, 1)
  231. tChatBG:SetFrameStrata('BACKGROUND')
  232. tChatBG:SetBackdropBorderColor(0, 0, 0, 1)
  233. --------------------------------------------------------
  234. --Handle the CombatLogBar that shows in up the 2nd tab--
  235. --------------------------------------------------------
  236. local f = CreateFrame('frame', nil, UIParent)
  237. f:RegisterEvent('ADDON_LOADED')
  238. f:SetScript('OnEvent', function(self, event, addon)
  239.     if addon == 'Blizzard_CombatLog' then
  240.         f:UnregisterEvent('ADDON_LOADED')
  241.         local _, parent = CombatLogQuickButtonFrame_Custom:GetPoint()
  242.         CombatLogQuickButtonFrame_Custom:SetPoint('BOTTOMRIGHT', parent, 'TOPRIGHT')
  243.         CombatLogQuickButtonFrame_CustomTexture:SetAlpha(0)
  244.         CombatLogQuickButtonFrameButton1:GetFontString():SetFont('Interface\\AddOns\\tChat\\Font.ttf', 10)
  245.         CombatLogQuickButtonFrameButton2:GetFontString():SetFont('Interface\\AddOns\\tChat\\Font.ttf', 10)
  246.     end
  247. end)
  248. -----------------------------------------------------------------------------------------------------------------------
  249. --Since we moved the chat tabs, this is necessary to fade in the chat elements when we mouse over the moved chat tabs--
  250. -----------------------------------------------------------------------------------------------------------------------
  251. local g = CreateFrame('frame', nil, UIParent)
  252. g.elapsed = 0
  253. g:SetScript('OnUpdate', function(self, elapsed)
  254.     self.elapsed = self.elapsed + elapsed
  255.     if self.elapsed > 0.1 then
  256.         for _, frameName in pairs(CHAT_FRAMES) do
  257.             local chatFrame = _G[frameName]
  258.             if chatFrame:IsShown() then
  259.                 if (ChatFrame1Tab:IsMouseOver() or ChatFrame2Tab:IsMouseOver()) then
  260.                     chatFrame.mouseOutTime = 0
  261.                     if (cursorX == LAST_CURSOR_X and cursorY == LAST_CURSOR_Y and not chatFrame.hasBeenFaded) then
  262.                         chatFrame.mouseInTime = (chatFrame.mouseInTime or 0) + elapsed
  263.                         if (chatFrame.mouseInTime > CHAT_TAB_SHOW_DELAY) then
  264.                             FCF_FadeInChatFrame(chatFrame)
  265.                         end
  266.                     else
  267.                         chatFrame.mouseInTime = 0
  268.                     end
  269.                 elseif (chatFrame:IsShown() and chatFrame.hasBeenFaded) then
  270.                     chatFrame.mouseInTime = 0
  271.                     chatFrame.mouseOutTime = (chatFrame.mouseOutTime or 0) + elapsed
  272.                     if (chatFrame.mouseOutTime > CHAT_TAB_HIDE_DELAY) then
  273.                         FCF_FadeOutChatFrame(chatFrame)
  274.                     end
  275.                 end
  276.             end
  277.         end
  278.         self.elapsed = 0
  279.     end
  280. end)
  281. -----------------------------------------------------------------------------------------------
  282. --This block of code makes it so player names show up as class colored in chat when typed out--
  283. -----------------------------------------------------------------------------------------------
  284. local function AddMessage(self, text, ...)
  285.     --Remove player brackets
  286.     text = text:gsub('|Hplayer:([^%|]+)|h%[([^%]]+)%]|h', '|Hplayer:%1|h%2|h')
  287.     --Remove Away and Busy Tags
  288.     text = text:gsub('<Away>', '')
  289.     text = text:gsub('<Busy>', '')
  290.  
  291.     --Strip yells: says: from chat
  292.     text = text:gsub('|Hplayer:([^%|]+)|h(.+)|h says:', '|Hplayer:%1|h%2|h:')
  293.     text = text:gsub('|Hplayer:([^%|]+)|h(.+)|h yells:', '|Hplayer:%1|h%2|h:')
  294.  
  295.     --Shorten GMotD and change online/offline warnings
  296.     text = text:gsub('Guild Message of the Day:', 'GMotD -')
  297.     text = text:gsub('has come online.', '+')
  298.     text = text:gsub('has gone offline.', '-')
  299.  
  300.     --channel replace (Trade and custom)
  301.     text = text:gsub('|h%[(%d+)%. .-%]|h', '|h%1.|h')
  302.  
  303.     --url search
  304.     text = text:gsub('([wWhH][wWtT][wWtT][%.pP]%S+[^%p%s])', '|cffffffff|Hurl:%1|h[%1]|h|r')
  305.  
  306.     return self.DefaultAddMessage(self, text, ...)
  307. end
  308.  
  309. local function RGBPercToHex(r, g, b)
  310.     r = r <= 1 and r >= 0 and r or 0
  311.     g = g <= 1 and g >= 0 and g or 0
  312.     b = b <= 1 and b >= 0 and b or 0
  313.     return string.format('%02x%02x%02x', r*255, g*255, b*255)
  314. end
  315.  
  316. local function colorName(self, event, msg, ...)
  317.     local test = msg:gsub('[^a-zA-Z%s]', '')
  318.     local words = {strsplit(' ', test)}
  319.     for i = 1, #words do
  320.         local w = words[i]
  321.         if (w and not (w == 'player' or w == 'target') and UnitName(w) and UnitIsPlayer(w)) then
  322.             local class = select(2, UnitClass(w))
  323.             local colors = RAID_CLASS_COLORS[class]
  324.             if (colors) then
  325.                 msg = gsub(msg, w, '|cff'..RGBPercToHex(colors.r, colors.g, colors.b)..'%1|r')
  326.             end
  327.         end
  328.     end
  329.  
  330.     return false, msg, ...
  331. end
  332.  
  333. ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL', colorName)
  334. ChatFrame_AddMessageEventFilter('CHAT_MSG_GUILD', colorName)
  335. ChatFrame_AddMessageEventFilter('CHAT_MSG_OFFICER', colorName)
  336. ChatFrame_AddMessageEventFilter('CHAT_MSG_SAY', colorName)
  337. ChatFrame_AddMessageEventFilter('CHAT_MSG_YELL', colorName)
  338. ChatFrame_AddMessageEventFilter('CHAT_MSG_PARTY', colorName)
  339. ChatFrame_AddMessageEventFilter('CHAT_MSG_PARTY_LEADER', colorName)
  340. ChatFrame_AddMessageEventFilter('CHAT_MSG_RAID', colorName)
  341. ChatFrame_AddMessageEventFilter('CHAT_MSG_RAID_LEADER', colorName)
  342. ChatFrame_AddMessageEventFilter('CHAT_MSG_RAID_WARNING', colorName)
  343. ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER', colorName)
  344. ChatFrame_AddMessageEventFilter('CHAT_MSG_BN_WHISPER_INFORM', colorName)
  345. ChatFrame_AddMessageEventFilter('CHAT_MSG_WHISPER', colorName)
  346. ChatFrame_AddMessageEventFilter('CHAT_MSG_WHISPER_INFORM', colorName)
  347. ------------------------------------------------------------------------------------
  348. --This block of code will make the chat appear slightly different, but streamlined--
  349. ------------------------------------------------------------------------------------
  350. CHAT_WHISPER_GET                = 'F %s '
  351. CHAT_WHISPER_INFORM_GET         = 'T %s '
  352. CHAT_BN_WHISPER_GET             = 'F %s '
  353. CHAT_BN_WHISPER_INFORM_GET      = 'T %s '
  354. CHAT_BATTLEGROUND_GET           = '|Hchannel:Battleground|hBG.|h %s: '
  355. CHAT_BATTLEGROUND_LEADER_GET    = '|Hchannel:Battleground|hBGL.|h %s: '
  356. CHAT_GUILD_GET                  = '|Hchannel:Guild|hG.|h %s: '
  357. CHAT_OFFICER_GET                = '|Hchannel:Officer|hO.|h %s: '
  358. CHAT_PARTY_GET                  = '|Hchannel:Party|hP.|h %s: '
  359. CHAT_PARTY_LEADER_GET           = '|Hchannel:Party|hPL.|h %s: '
  360. CHAT_PARTY_GUIDE_GET            = '|Hchannel:Party|hPG.|h %s: '
  361. CHAT_RAID_GET                   = '|Hchannel:Raid|hR.|h %s: '
  362. CHAT_RAID_LEADER_GET            = '|Hchannel:Raid|hRL.|h %s: '
  363. CHAT_RAID_WARNING_GET           = '|Hchannel:RaidWarning|hRW.|h %s: '
  364. CHAT_INSTANCE_CHAT_GET          = '|Hchannel:Battleground|hI.|h %s: '
  365. CHAT_INSTANCE_CHAT_LEADER_GET   = '|Hchannel:Battleground|hIL.|h %s: '
  366. YOU_LOOT_MONEY_GUILD            = YOU_LOOT_MONEY
  367. LOOT_MONEY_SPLIT_GUILD          = LOOT_MONEY_SPLIT
  368. ----------------------------------------------------------------------------------------------------------------------
  369. --alt click invite players and when clicked on things deemed url, open the edit box and select all the text for copy--
  370. ----------------------------------------------------------------------------------------------------------------------
  371. local DefaultSetItemRef = SetItemRef
  372. function SetItemRef(link, ...)
  373.     local type, value = link:match('(%a+):(.+)')
  374.     if IsAltKeyDown() and type == 'player' then
  375.         InviteUnit(value:match('([^:]+)'))
  376.     elseif (type == 'url') then
  377.         local eb = LAST_ACTIVE_CHAT_EDIT_BOX or ChatFrame1EditBox
  378.         if not eb then return end
  379.         eb:Show()
  380.         eb:SetText(value)
  381.         eb:SetFocus()
  382.         eb:HighlightText()
  383.     else
  384.         return DefaultSetItemRef(link, ...)
  385.     end
  386. end
  387. --------------------------
  388. --Call our Main Function--
  389. --------------------------
  390. for i = 1, NUM_CHAT_WINDOWS do
  391.     local frame = _G['ChatFrame'..i]
  392.     tChatMain(frame)
  393.     if (i ~= 2) then
  394.         frame.DefaultAddMessage = frame.AddMessage --idk what all of this is
  395.         frame.AddMessage = AddMessage --idk what all of this is
  396.     end
  397. end
  398. ------------------------------------------------------
  399. --This will handle temporary frames like pet battles--
  400. ------------------------------------------------------
  401. hooksecurefunc('FCF_OpenTemporaryWindow', function()
  402.     for _, name in next, CHAT_FRAMES do
  403.         local frame = _G[name]
  404.         if (frame.isTemporary) then
  405.             tChatMain(frame)
  406.         end
  407.     end
  408. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top