From ac373d4e00ea0b19aec8a56ff64d8e2063868692 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Tue, 11 Jan 2011 13:48:40 +0000 Subject: [PATCH] Add options for logging/tooltip/feed --- CaptainsLog.lua | 80 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/CaptainsLog.lua b/CaptainsLog.lua index 9cf94c4..b3a1c54 100644 --- a/CaptainsLog.lua +++ b/CaptainsLog.lua @@ -16,6 +16,29 @@ function addon:Initialize() ["*"] = {}, }, }, + profile = { + showinfeed = { + L["Whisper"] = true, + L["Party"] = true, + L["Guild"] = true, + L["Battle.net"] = true, + L["Raid"] = true, + }, + showintooltip = { + L["Whisper"] = true, + L["Party"] = true, + L["Guild"] = true, + L["Battle.net"] = true, + L["Raid"] = true, + }, + log = { + L["Whisper"] = false, + L["Party"] = false, + L["Guild"] = false, + L["Battle.net"] = false, + L["Raid"] = false, + } + }, }) self.messages = self.db.char.messages @@ -57,19 +80,18 @@ function addon:Log(mtype, sender, msg) sender = sender, msg = msg, } - - self:UpdateFeedText(mtype, sender) end function addon:UpdateFeedText(mtype, sender) - self.feed.text = L["%s from %s"]:format(mtype, sender) + if addon.db.profile.showinfeed[mtype] then + self.feed.text = L["%s from %s"]:format(mtype, sender) + end end local colorMap = { ["Party"] = "PARTY", ["Guild"] = "GUILD", ["Whisper"] = "WHISPER", - ["Party"] = "PARTY", ["Raid"] = "RAID", ["Battle.net"] = "BN_WHISPER", } @@ -90,23 +112,25 @@ function addon:PopulateTooltip(tooltip) table.sort(sort) for idx, mtype in ipairs(sort) do - local c = ChatTypeInfo[colorMap[mtype]] or {} + if addon.db.profile.showintooltip[mtype] then + local c = ChatTypeInfo[colorMap[mtype]] or {} - if idx > 1 then - self:AddSpacerLine(tooltip, 3, 0.6, 0.6, 0.6) - end + if idx > 1 then + self:AddSpacerLine(tooltip, 3, 0.6, 0.6, 0.6) + end - tooltip:AddLine(mtype) + tooltip:AddLine(mtype) - if #self.messages[mtype] > 0 then - for idx, msg in ipairs(self.messages[mtype]) do - tooltip:AddLine( + if #self.messages[mtype] > 0 then + for idx, msg in ipairs(self.messages[mtype]) do + tooltip:AddLine( string.format("[%s]: %s", msg[2], msg[3]), c.r, c.g, c.b - ) + ) + end + else + tooltip:AddLine(L["No messages"]) end - else - tooltip:AddLine(L["No messages"]) end end @@ -116,27 +140,43 @@ function addon:PopulateTooltip(tooltip) end function addon:CHAT_MSG_WHISPER(event, msg, sender, ...) + local mtype = L["Whisper"] + if not addon.db.profile.log[mtype] then return end + local cname = GetColoredName(event, msg, sender, ...) - self:Log(L["Whisper"], cname, msg) + self:Log(mtype, cname, msg) + self:UpdateFeedText(mtype, cname) end function addon:CHAT_MSG_GUILD(event, msg, sender, ...) + local mtype = L["Guild"] + if not addon.db.profile.log[mtype] then return end local cname = GetColoredName(event, msg, sender, ...) - self:Log(L["Guild"], cname, msg) + self:Log(mtype, cname, msg) + self:UpdateFeedText(mtype, cname) end function addon:CHAT_MSG_PARTY(event, msg, sender, ...) + local mtype = L["Party"] + if not addon.db.profile.log[mtype] then return end local cname = GetColoredName(event, msg, sender, ...) - self:Log(L["Party"], cname, msg) + self:Log(mtype, cname, msg) + self:UpdateFeedText(mtype, cname) end function addon:CHAT_MSG_BN_WHISPER(event, msg, sender, ...) - self:Log(L["Battle.net"], sender, msg) + local mtype = L["Battle.net"] + if not addon.db.profile.log[mtype] then return end + self:Log(mtype, sender, msg) + self:UpdateFeedText(mtype, sender) end function addon:CHAT_MSG_RAID(event, msg, sender, ...) + local mtype = L["Raid"] + if not addon.db.profile.log[mtype] then return end local cname = GetColoredName(event, msg, sender, ...) - self:Log(L["Raid"], cname, msg) + self:Log(mtype, cname, msg) + self:UpdateFeedText(mtype, cname) end --[[------------------------------------------------------------------------- -- 1.7.9.5