02-26-10, 05:35 AM | #1 |
chat formatting (oChat)
Hello. I'm trying to modify the formatting of chat with oChat to my liking. Basically:
guild chat: 1245 Hunterx: blah say: 1245 Mightydk: hallo! trade: 1245 Bankalt: WTS lots of expensive stuff Emote: 1245 You are hungry! etc. Basically: -The only indication for channels is the color -No brackets around names -That's about it? So far I haven't successfully been able to do this without some not working as intended stuff. I think this is the relevant part: Code:
local ts = "|cffffffff|HoChat|h%s|h|r %s" local origs = {} CHAT_GUILD_GET = '|Hchannel:Guild|h%s:\32' ... other chats -- 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" 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 = ts:format(date"%H%M", text) end return _AddMessage(self, text, ...) end CHAT_GUILD_GET = '|Hchannel:Guild|h%s:\32' If I change that to CHAT_GUILD_GET = '|Hchannel:Guild|h\32|h%s:\32' the names are clickable but there's an extra space between timestamp and name. Also in each case the names have brackets of course. If I change local ts = "|cffffffff|HoChat|h%s|h|r %s" to Code:
local ts = "|cffffffff|HoChat|h%s|h|r%s" --AND local str = " %3$s" --AND CHAT_GUILD_GET = '|Hchannel:Guild|h |h%s:\32' At one point I had Code:
if(type(text) == "string") then text = text:gsub("|Hplayer:([^:]+):(%d+)|h%[(.-)%]|h", "|Hplayer:%1:%2|h%3|h") text = text:gsub("%[(%d+)%. (.+)%].+(|Hplayer.+)", channel) text = ts:format(date"%H%M", text) end Is there someone who could help me with this? Last edited by Pseudopod : 02-26-10 at 05:41 AM. |
|
02-26-10, 06:31 AM | #2 |
Look at the code of ncChat.
__________________
Three things are certain, Death, taxes and site not found, You, victim of one. |
|
02-26-10, 06:51 AM | #3 | |
Beoko
Guest
Posts: n/a
|
This is much easier to accomplish than you think.
Change the CHAT_GUILD_GET to this: Code:
CHAT_GUILD_GET = '|Hchannel:Guild|h|h%s:\32' Code:
local AddMessage = function(self, text, ...) text = gsub(text, "%[%d+%. %w+%]", "") text = ts:format(date"%H%M", text) return _AddMessage(self, text, ...) end |
|
Beoko |
02-26-10, 07:18 AM | #4 | |
"|Hchannel:GuildHunterx: hey guild!" It seems to need something to replace the channel name with. At nightcracker's suggestion I looked at ncChat's code (I've tried to view idChat for help previously btw) and added the second text = text:gsub, which works for removing the brackets. Thanks for that. Code:
local AddMessage = function(self, text, ...) if(type(text) == "string") then text = text:gsub('|Hchannel:(%d+)|h%[?(.-)%]?|h.+(|Hplayer.+)', channel) text = text:gsub("(|Hplayer.-|h)%[(.-)%]|h", "%1%2|h") text = ts:format(date"%H%M", text) end return _AddMessage(self, text, ...) end |
||
02-26-10, 07:38 AM | #5 | |
Beoko
Guest
Posts: n/a
|
I'm sorry. I've never really bothered completely omitting channel numbers or names so I never bothered to test embedded hyperlinks directly next to each other. I just tested this in game, it will not show the trailing guild hyperlink and it will let you click the player to send them a tell:
Code:
CHAT_GUILD_GET = '|h%s:\32' |
|
Beoko |
02-26-10, 07:49 AM | #6 |
Eehm, as I told you, look at the code of ncChat and your a lot closer to your goal. But I'm nice, so I did the work for you:
Code:
text = text:gsub("|Hchannel:[^|]+|h[^|]+|h ", "") text = text:gsub("(|Hplayer.-|h)%[(.-)%]|h", "%1%2|h")
__________________
Three things are certain, Death, taxes and site not found, You, victim of one. |
|
02-26-10, 07:55 AM | #7 | ||
edit: Something I noticed though. oChat's memory usage is now 99.96 KB. What's up? Last edited by Pseudopod : 02-26-10 at 08:03 AM. |
|||
02-26-10, 08:00 AM | #8 | ||
Beoko
Guest
Posts: n/a
|
Oh, no worries. I didn't mean to come off sounding like you sounded snappy if I did, either. ^^ |
||
Beoko |
02-26-10, 08:13 AM | #9 | |
Beoko
Guest
Posts: n/a
|
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?
|
|
Beoko |
02-26-10, 08:19 AM | #10 |
ncChat uses the same method and has 7kB mem usage. Must be some memory leak of some kind. Make sure to use /run collectgarbage("collect") before comparising mem usage though.
__________________
Three things are certain, Death, taxes and site not found, You, victim of one. |
|
02-26-10, 08:21 AM | #11 | |
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 |
||
02-26-10, 08:23 AM | #12 |
Off topic: Why are so many people worried about memory? You seriously concerned that oChat is using under 1 MB of memory?
|
|
02-26-10, 08:28 AM | #13 | |
I.g. If there are 3 minimap addons that all can be made to look the same, I will choose the one with no config and minimal code over one that has a in-game config and lots of other stuff I don't need at all. In static things like minimap and chat where it's all about how you want something to look, I prefer the minimalistic version. When it comes to boss mods, I will choose the one that has the best warnings and timers over one that uses less memory but doesn't have everything I need. In addition, since I'm not a lua expert at all and I'm still tweaking the code to my liking, something like that also is the only way of knowing if my editings are baaaad. (I've edited this like 100 times now lol). Immediately after garbage collection the mem usage is now (with a "polished" version) 1.44 kb. It goes steadily up, but that's just normal cause it does need to edit every line? Last edited by Pseudopod : 02-26-10 at 08:38 AM. |
||
02-26-10, 08:32 AM | #14 | ||
Beoko
Guest
Posts: n/a
|
Static memory is very harmless, but memory leaks can cause quite a few issues. I'm sure we wouldn't have reacted the same if oChat was supposed to be about 100 kB normally. |
||
Beoko |
02-26-10, 09:03 AM | #15 |
Because normally the addon uses 2kB but all of a sudden it uses 50 times as much. That makes you wonder
__________________
Three things are certain, Death, taxes and site not found, You, victim of one. |
|
02-26-10, 04:37 PM | #16 |
It was a general question though :P But yeah, I guess people just aren't sure why they like low memory addons and interfaces :P Right now, my interface uses roughly 46MB lol, but I have no issues.
|
|
WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » chat formatting (oChat) |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|