Quantcast

Add options for logging/tooltip/feed

James Whitehead II [01-11-11 - 13:48]
Add options for logging/tooltip/feed
Filename
CaptainsLog.lua
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

 --[[-------------------------------------------------------------------------