Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-26-10, 08:21 AM   #14
Pseudopod
A Deviate Faerie Dragon
Join Date: Apr 2008
Posts: 16
Originally Posted by Beoko View Post
Could be any number of things, but if I were to guess... calling two gsubs per AddMessage can add up if you have an excessive amount of chat happening. Mind posting your entirely edited lua file now?
Code:
local type = type
local tonumber = tonumber
local string_split = string.split
 
local _AddMessage = ChatFrame1.AddMessage
local _SetItemRef = SetItemRef
 
local buttons = {"UpButton", "DownButton", "BottomButton"}
local dummy = function() end
local ts = "|cffffffff|HoChat|h%s|h|r %s"
 
local origs = {}
 
local blacklist = {
	[ChatFrame2] = true,
	[ChatFrame4] = true,
}
 
CHAT_SAY_GET = '|Hchannel:Say|h*|h%s:\32'
CHAT_GUILD_GET = '|h%s:\32'
CHAT_RAID_GET = "|Hchannel:raid|h*|h%s:\32"
CHAT_PARTY_GET = "|Hchannel:Party|h*|h%s:\32"
CHAT_PARTY_LEADER_GET = '|Hchannel:party|h*|h%s:\32'
CHAT_PARTY_GUIDE_GET =  CHAT_PARTY_LEADER_GET
CHAT_RAID_WARNING_GET = "! %s:\32"
CHAT_RAID_LEADER_GET = "|Hchannel:raid|h*|h%s:\32"
CHAT_OFFICER_GET = "|Hchannel:o|h*|h%s:\32"
CHAT_BATTLEGROUND_GET = "|Hchannel:Battleground|h*|h%s:\32"
CHAT_BATTLEGROUND_LEADER_GET = "|Hchannel:Battleground|h*|h%s:\32"
 
-- 1: index, 2: channelname, 3: twatt
-- Examples are based on this: [1. Channel] Otravi: Hi
--local str = "[%2$.3s] %s" -- gives: [Cha] Otravi: Hi
--local str = "[%d. %2$.3s] %s" -- gives: [1. Cha] Otravi: Hi
local str = "%3$s" -- gives: 1 Otravi: Hi
local channel = function(...)
	return str:format(...)
end
 
local AddMessage = function(self, text, ...)
	if(type(text) == "string") then
	--text = text:gsub('|Hchannel:(%d+)|h%[?(.-)%]?|h.+(|Hplayer.+)', channel)
	text = text:gsub("|Hchannel:[^|]+|h[^|]+|h ", "")
	text = text:gsub("(|Hplayer.-|h)%[(.-)%]|h", "%1%2|h")
		text = ts:format(date"%H%M", text)
	end

	return _AddMessage(self, text, ...)
end

local scroll = function(self, dir)
	if(dir > 0) then
		if(IsShiftKeyDown()) then
			self:ScrollToTop()
		else
			self:ScrollUp()
		end
	elseif(dir < 0) then
		if(IsShiftKeyDown()) then
			self:ScrollToBottom()
		else
			self:ScrollDown()
		end
	end
end
 
for i=1, NUM_CHAT_WINDOWS do
	local cf = _G["ChatFrame"..i]
	cf:EnableMouseWheel(true)
 
	cf:SetFading(false)
	cf:SetScript("OnMouseWheel", scroll)
 
	for k, button in pairs(buttons) do
		button = _G["ChatFrame"..i..button]
		button:Hide()
		button.Show = dummy
	end
 
	if(not blacklist[cf]) then
		origs[cf] = cf.AddMessage
		cf.AddMessage = AddMessage
	end
end
 
buttons = nil
 
ChatFrameMenuButton:Hide()
ChatFrameMenuButton.Show = dummy
 
local eb = ChatFrameEditBox
eb:ClearAllPoints()
eb:SetAltArrowKeyMode(false)
eb:SetPoint("CENTER", "UIParent", 0, 0)
eb:SetPoint("CENTER", "UIParent", 0, 0)
eb:SetWidth(350)
 
local a, b, c = select(6, eb:GetRegions())
a:Hide(); b:Hide(); c:Hide()
 
ChatTypeInfo['SAY'].sticky = 1
ChatTypeInfo['YELL'].sticky = 1
ChatTypeInfo['PARTY'].sticky = 1
ChatTypeInfo['GUILD'].sticky = 1
ChatTypeInfo['OFFICER'].sticky = 1
ChatTypeInfo['RAID'].sticky = 1
ChatTypeInfo['RAID_WARNING'].sticky = 1
ChatTypeInfo['BATTLEGROUND'].sticky = 1
ChatTypeInfo['WHISPER'].sticky = 1
ChatTypeInfo['CHANNEL'].sticky = 1
 
-- Modified version of MouseIsOver from UIParent.lua
local MouseIsOver = function(frame)
	local s = frame:GetParent():GetEffectiveScale()
	local x, y = GetCursorPosition()
	x = x / s
	y = y / s
 
	local left = frame:GetLeft()
	local right = frame:GetRight()
	local top = frame:GetTop()
	local bottom = frame:GetBottom()
 
	-- Hack to fix a symptom not the real issue
	if(not left) then
		return
	end
 
	if((x > left and x < right) and (y > bottom and y < top)) then
		return 1
	else
		return
	end
end
 
local borderManipulation = function(...)
	for l = 1, select("#", ...) do
		local obj = select(l, ...)
		if(obj:GetObjectType() == "FontString" and MouseIsOver(obj)) then
			return obj:GetText()
		end
	end
end

SetItemRef = function(link, text, button, ...)
	if(link:sub(1, 5) ~= "oChat") then return _SetItemRef(link, text, button, ...) end
 
	local text = borderManipulation(SELECTED_CHAT_FRAME:GetRegions())
	if(text) then
		text = text:gsub("|c%x%x%x%x%x%x%x%x(.-)|r", "%1")
		text = text:gsub("|H.-|h(.-)|h", "%1")
 
		eb:Insert(text)
		eb:Show()
		eb:HighlightText()
		eb:SetFocus()
	end
end
(It's not polished yet :P) When I removed the last "SetItemRef = function(link, text, button, ...)" part it dropped to 2kb actually.
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » chat formatting (oChat)


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off