Thread Tools Display Modes
10-22-09, 02:45 PM   #1
khurzog
A Frostmaul Preserver
 
khurzog's Avatar
Join Date: Dec 2007
Posts: 266
Question restore chat

is there an addon that will restore all chat history after reloading UI? if not i would love to see one soon. thanks
  Reply With Quote
10-22-09, 02:53 PM   #2
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Code:
--Disclaimer: For anyone who attempts to read my code..... I'm sorry. 
local addon = CreateFrame("Frame") 
local db 
 
local origadds = { 
    [ChatFrame1] = ChatFrame1.AddMessage, 
    --[ChatFrame2] = ChatFrame2.AddMessage, 
    [ChatFrame3] = ChatFrame3.AddMessage, 
    [ChatFrame4] = ChatFrame4.AddMessage, 
    [ChatFrame5] = ChatFrame5.AddMessage, 
    [ChatFrame6] = ChatFrame6.AddMessage 
} 
 
local tblsizes = setmetatable({}, {__index = function() return 0 end}) --nil == 0 
local function NewAddMessage(f, msg, r, g, b, ...) 
    if msg then --print(nil) breaks things. 
        local tbl = db[f:GetName()] 
        local msgs, colours = tbl.msgs, tbl.colours 
        if tblsizes[tbl] > 50 then 
            tremove(msgs, 1) 
            tremove(colours, 1) 
            tremove(colours, 1) 
            tremove(colours, 1) 
        else 
            tblsizes[tbl] = tblsizes[tbl] + 1 
        end 
        tinsert(msgs, msg) 
        tinsert(colours, r or 1) 
        tinsert(colours, g or 1) 
        tinsert(colours, b or 1) 
    end 
    return origadds[f](f, msg, r, g, b, ...) 
end 
 
--Hook nice n' early 
ChatFrame1.AddMessage = NewAddMessage 
--ChatFrame2.AddMessage = NewAddMessage 
ChatFrame3.AddMessage = NewAddMessage 
ChatFrame4.AddMessage = NewAddMessage 
ChatFrame5.AddMessage = NewAddMessage 
ChatFrame6.AddMessage = NewAddMessage 
local givetblmt 
givetblmt = {__index = function(t, k) 
    local newt = setmetatable({}, givetblmt) 
    t[k] = newt 
    return newt 
end} 
 
addon:SetScript("OnEvent", function(self) 
    TransScriptDB = setmetatable(TransScriptDB or {}, givetblmt) 
    db = TransScriptDB 
    local f 
    local msgs, colours, x 
    for name, tbl in pairs(db) do 
        f = _G[name] 
        if f and f.AddMessage then 
            msgs, colours = tbl.msgs, tbl.colours 
            tblsizes[tbl] = #msgs 
            for i = 1, tblsizes[tbl] do 
                x = (i-1)*3+1 
                origadds[f](f, "|cFFFF7722>|r "..msgs[i], colours[x], colours[x+1], colours[x+2]) 
            end 
        end 
    end 
    self:UnregisterEvent("ADDON_LOADED") 
    self:SetScript("OnEvent", nil) 
 
end) 
 
addon:RegisterEvent("ADDON_LOADED")
This is what I've been using for a long time, I'm pretty sure theres a better way to do it, but this is good enough for me.

Just make an addon and add this to the toc:
## SavedVariablesPerCharacter: TransScriptDB

Last edited by Slakah : 10-22-09 at 03:01 PM.
  Reply With Quote
10-22-09, 05:28 PM   #3
khurzog
A Frostmaul Preserver
 
khurzog's Avatar
Join Date: Dec 2007
Posts: 266
awesome im going to try that, also w/o starting a new thread i wanted to add another inquiry/request.

since only chat frame 1 is able to have other chat frames docked with it, is there an addon that will create a second set of docked chat frames? that would really make my day =D thanks!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » restore chat


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