Quantcast

log-o-matic returns

Steven Jackson [07-29-14 - 22:31]
log-o-matic returns
Filename
Interface/AddOns/SVUI/packages/dock/SVDock.lua
Interface/AddOns/SVUI/system/system.lua
Interface/AddOns/SVUI_ConfigOMatic/modules/chat.lua
Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua
diff --git a/Interface/AddOns/SVUI/packages/dock/SVDock.lua b/Interface/AddOns/SVUI/packages/dock/SVDock.lua
index 3c02718..1fdc0c6 100644
--- a/Interface/AddOns/SVUI/packages/dock/SVDock.lua
+++ b/Interface/AddOns/SVUI/packages/dock/SVDock.lua
@@ -51,7 +51,7 @@ local TOOL_DATA = {
 	[171] 	= {0,0.25,0,0.25}, 				-- PRO-ALCHEMY
     [794] 	= {0.25,0.5,0,0.25,80451}, 		-- PRO-ARCHAELOGY
     [164] 	= {0.5,0.75,0,0.25}, 			-- PRO-BLACKSMITH
-    [185] 	= {0.75,1,0,0.25,818,93636}, 	-- PRO-COOKING
+    [185] 	= {0.75,1,0,0.25,818,67097}, 	-- PRO-COOKING
     [333] 	= {0,0.25,0.25,0.5,13262}, 		-- PRO-ENCHANTING
     [202] 	= {0.25,0.5,0.25,0.5}, 			-- PRO-ENGINEERING
     [129] 	= {0.5,0.75,0.25,0.5}, 			-- PRO-FIRSTAID
@@ -615,27 +615,8 @@ do
 	local LastAddedMacro;
 	local MacroCount = 0;

-	local Macro_OnEnter = function(self)
-		self:SetPanelColor("highlight")
-	    self.icon:SetGradient(unpack(SuperVillain.Media.gradient.bizzaro))
-		GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", 2, 4)
-		GameTooltip:ClearLines()
-		if not self.TText2 then
-			GameTooltip:AddLine(self.TText, 1, 1, 1)
-		else
-			GameTooltip:AddDoubleLine(self.TText, self.TText2, 1, 1, 1)
-		end
-		GameTooltip:Show()
-	end
-
-	local Macro_OnLeave = function(self)
-		self:SetPanelColor("special")
-		self.icon:SetGradient("VERTICAL", 0.5, 0.53, 0.55, 0.8, 0.8, 1)
-		GameTooltip:Hide()
-	end
-
-	local function HearthTime()
-		local start,duration = GetItemCooldown(6948)
+	local function GetMacroCooldown(itemID)
+		local start,duration = GetItemCooldown(itemID)
 		local expires = duration - (GetTime() - start)
 		if expires > 0.05 then
 			local timeLeft = 0;
@@ -662,6 +643,31 @@ do
 		end
 	end

+	local Macro_OnEnter = function(self)
+		self:SetPanelColor("highlight")
+	    self.icon:SetGradient(unpack(SuperVillain.Media.gradient.bizzaro))
+		GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", 2, 4)
+		GameTooltip:ClearLines()
+		if not self.TText2 then
+			GameTooltip:AddLine("Open " .. self.TText, 1, 1, 1)
+		else
+			GameTooltip:AddDoubleLine("[Click]", "Open " .. self.TText, 0, 1, 0, 1, 1, 1)
+			GameTooltip:AddDoubleLine("[Shift-Click]", "Use " .. self.TText2, 0, 1, 0, 1, 1, 1)
+			if(self.IsItem) then
+				GameTooltip:AddLine(" ", 1, 1, 1)
+				local remaining = GetMacroCooldown(self.IsItem)
+				GameTooltip:AddDoubleLine(self.TText2, remaining, 1, 0.5, 0, 0, 1, 1)
+			end
+		end
+		GameTooltip:Show()
+	end
+
+	local Macro_OnLeave = function(self)
+		self:SetPanelColor("special")
+		self.icon:SetGradient("VERTICAL", 0.5, 0.53, 0.55, 0.8, 0.8, 1)
+		GameTooltip:Hide()
+	end
+
 	local Hearth_OnEnter = function(self)
 		if InCombatLockdown() then return end
 		self.glow:Show()
@@ -669,7 +675,7 @@ do
 		GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", 0, 4)
 		GameTooltip:ClearLines()
 		GameTooltip:AddLine(L["Hearthstone"], 1, 1, 1)
-		local remaining = HearthTime()
+		local remaining = GetMacroCooldown(6948)
 		GameTooltip:AddDoubleLine(L["Time Remaining"], remaining, 1, 1, 1, 0, 1, 1)
 		if(self.ExtraSpell) then
 			GameTooltip:AddLine(" ", 1, 1, 1)
@@ -714,19 +720,25 @@ do
 		button.icon:SetGradient("VERTICAL", 0.5, 0.53, 0.55, 0.8, 0.8, 1)
 		button.skillName = proName;
 		button.itemId = itemID;
-		button.TText = "Open " .. proName;
-		button:SetAttribute("type", "macro")
+		button.TText = proName;
+
 		if(data[5]) then
-			local rcSpellID = data[5]
-			if(data[6] and IsSpellKnown(data[6])) then
-				rcSpellID = data[6]
+			local rightClick
+			button:RegisterForClicks("AnyDown")
+			if(data[6] and GetItemCount(data[6], true) > 0) then
+				rightClick = GetItemInfo(data[6])
+				button.IsItem = data[6]
+			else
+				rightClick = GetSpellInfo(data[5])
 			end
-			local rightClickSpell = GetSpellInfo(rcSpellID)
-			button:SetAttribute("macrotext", "/cast [mod:shift]" .. rightClickSpell .. "; " .. proName)
-			button.TText2 = "Shift-Click to use " .. rightClickSpell
-		else
-			button:SetAttribute("macrotext","/cast " .. proName)
-		end
+			button:SetAttribute("type", "macro")
+			button:SetAttribute("macrotext", "/cast [button:2] " .. rightClick .. ";" .. proName)
+			button.TText2 = rightClick
+		else
+			button:SetAttribute("type", "macro")
+			button:SetAttribute("macrotext", "/cast " .. proName)
+		end
+
 		button:SetScript("OnEnter", Macro_OnEnter)
 		button:SetScript("OnLeave", Macro_OnLeave)
 	end
diff --git a/Interface/AddOns/SVUI/system/system.lua b/Interface/AddOns/SVUI/system/system.lua
index 8407ee6..ccbda5e 100644
--- a/Interface/AddOns/SVUI/system/system.lua
+++ b/Interface/AddOns/SVUI/system/system.lua
@@ -102,7 +102,7 @@ THE CLEANING LADY
 ##########################################################
 ]]--
 -- local LemonPledge = 0;
--- local Consuela = CreateFrame("Frame")
+-- local Consuela = CreateFrame("Frame", nil)
 -- Consuela:RegisterAllEvents()
 -- Consuela:SetScript("OnEvent", function(self, event)
 -- 	LemonPledge = LemonPledge + 1
diff --git a/Interface/AddOns/SVUI_ConfigOMatic/modules/chat.lua b/Interface/AddOns/SVUI_ConfigOMatic/modules/chat.lua
index a7ce0cc..dcc2bd8 100644
--- a/Interface/AddOns/SVUI_ConfigOMatic/modules/chat.lua
+++ b/Interface/AddOns/SVUI_ConfigOMatic/modules/chat.lua
@@ -70,7 +70,9 @@ SuperVillain.Options.args.SVChat={
 					order = 2,
 					type = "toggle",
 					name = L["Save Chats"],
-					desc = L["Retain chat messages even after logging out."]
+					desc = L["Retain chat messages even after logging out."],
+					get = function(a)return SuperVillain.db.SVChat[a[#a]]end,
+					set = function(a,b)MOD:ChangeDBVar(b,a[#a]);MOD:ReLoad() end,
 				},
 				url = {
 					order = 3,
diff --git a/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua b/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua
index 0060dcf..2abf3ad 100644
--- a/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua
+++ b/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua
@@ -31,7 +31,7 @@ local format = string.format;
 --[[ MATH METHODS ]]--
 local floor = math.floor;
 --[[ TABLE METHODS ]]--
-local twipe,tcopy = table.wipe, table.copy;
+local twipe,tcopy,tsort = table.wipe, table.copy, table.sort;
 --[[
 ##########################################################
 GET ADDON DATA
@@ -130,7 +130,7 @@ local RefreshLoggedSlot = function(self, bag, slotID, save)
 		end
 		if (key and save) then
 			local id = GetContainerItemID(bag,slotID)
-			LOG.myStash[bag][key] = GetItemCount(id,true);
+			if id ~= 6948 then LOG.myStash[bag][key] = GetItemCount(id,true) end
 		end
 	else
 		slot:SetBackdropBorderColor(0, 0, 0)
@@ -150,8 +150,6 @@ local RefreshLoggedBagSlots = function(self, bag, save)
 	for i = 1, GetContainerNumSlots(bag)do
 		local container = self
 		if not self.RefreshSlot then
-			self:RefreshSlot(bag, i, save)
-		else
 			container = self:GetParent()
 		end
 		RefreshLoggedSlot(container, bag, i, save)
@@ -178,47 +176,26 @@ local RefreshLoggedBagsSlots = function(self)
 	end
 end

-local GameTooltip_OnTooltipSetItem = function(self,tooltip)
-	if not tooltip.itemCleared then
-		local key,itemID = tooltip:GetItem()
-		local left = "";
-		local right = "";
-		if LOG.BagItemCache[key] then
-			tooltip:AddLine(" ")
-			tooltip:AddDoubleLine("|cFFCA3C3C[Character]|r","|cFFCA3C3C[Bags/Bank]|r")
-			for alt,amt in pairs(LOG.BagItemCache[key]) do
-				local result = ("|cFF00FFFF%d|r"):format(amt)
-				tooltip:AddDoubleLine(alt,result)
-			end
-			tooltip:AddLine(" ")
+local GameTooltip_LogTooltipSetItem = function(self)
+	local key,itemID = self:GetItem()
+	if LOG.BagItemCache[key] then
+		self:AddLine(" ")
+		self:AddDoubleLine("|cFFFFDD3C[Character]|r","|cFFFFDD3C[Count]|r")
+		for alt,amt in pairs(LOG.BagItemCache[key]) do
+			local hexString = SVLOG_Data[realmKey]["info"][alt]
+			local name = ("%s%s|r"):format(hexString, alt)
+			local result = ("%s%s|r"):format(hexString, amt)
+			self:AddDoubleLine(name,result)
 		end
-		if itemID ~= nil and SuperVillain.db.SVTip.spellID then
-			left = "|cFFCA3C3CID: |r"
-			right = ("|cFFCA3C3C%s|r %s"):format(ID,itemID):match(":(%w+)")
-		end
-		if left ~= "" or right ~= "" then
-			tooltip:AddLine(" ")
-			tooltip:AddDoubleLine(left,right)
-		end
-		tooltip.itemCleared = true
+		self:AddLine(" ")
 	end
+	self.itemLogged = true
 end
 --[[
 ##########################################################
 CORE FUNCTIONS
 ##########################################################
 ]]--
-function LOG:BuildCachedInventory()
-	for alt,_ in pairs(LOG.stash) do
-		for bag,items in pairs(LOG.stash[alt]) do
-			for id,amt in pairs(items) do
-				LOG.BagItemCache[id] = LOG.BagItemCache[id] or {}
-				LOG.BagItemCache[id][alt] = amt
-			end
-		end
-	end
-end
-
 function CHAT:LoadSavedChatLog()
 	local temp, data = {}
 	for id, _ in pairs(SVLOG_Cache["chat"]) do
@@ -230,31 +207,13 @@ function CHAT:LoadSavedChatLog()
 	for i = 1, #temp do
 		data = SVLOG_Cache["chat"][tostring(temp[i])]
 		if type(data) == "table" and data[20] ~= nil then
-			CHAT.timeOverride = temp[i]
+			self.timeOverride = temp[i]
 			ChatFrame_MessageEventHandler(DEFAULT_CHAT_FRAME, data[20], unpack(data))
 		end
 	end
 end

 function CHAT:LogCurrentChat(event, ...)
-	if CHAT.db.throttleInterval ~= 0 and (event == 'CHAT_MESSAGE_SAY' or event == 'CHAT_MESSAGE_YELL' or event == 'CHAT_MSG_CHANNEL') then
-		local msg, sender = ...
-		local message = sender:upper()..msg;
-		if sender ~= "" then
-			if CHAT.MessageCache["list"][message] == nil then
-				CHAT.MessageCache["list"][message] = true
-				CHAT.MessageCache["count"][message] = 1
-				CHAT.MessageCache["time"][message] = time()
-			else
-				CHAT.MessageCache["count"][message] = CHAT.MessageCache["count"][message] + 1
-			end
-		end
-		if sender ~= UnitName("player") and CHAT.MessageCache["list"][message] then
-			if difftime(time(), CHAT.MessageCache["time"][message]) <= CHAT.db.throttleInterval then
-				return;
-			end
-		end
-	end
 	local temp = {}
 	for i = 1, select('#', ...) do
 		temp[i] = select(i, ...) or false
@@ -291,7 +250,7 @@ function CHAT:PLAYER_ENTERING_WORLD()
 			ChatFrame_MessageEventHandler(DEFAULT_CHAT_FRAME, data[20], unpack(data))
 		end
 	end
-	CHAT:UnregisterEvent("PLAYER_ENTERING_WORLD")
+	self:UnregisterEvent("PLAYER_ENTERING_WORLD")
 end

 function LOG:AppendBankFunctions()
@@ -300,6 +259,15 @@ function LOG:AppendBankFunctions()
 		BAGS.BankFrame.RefreshBagsSlots = RefreshLoggedBagsSlots
 	end
 end
+
+function LOG:AppendChatFunctions()
+	if SuperVillain.db.SVChat.enable and SuperVillain.db.SVChat.saveChats then
+		for _,event in pairs(LoggingEvents) do
+			SuperVillain.SVChat:RegisterEvent(event, "LogCurrentChat")
+		end
+		SuperVillain.SVChat:RegisterEvent("PLAYER_ENTERING_WORLD")
+	end
+end
 --[[
 ##########################################################
 CORE FUNCTIONS
@@ -336,11 +304,15 @@ BUILD FUNCTION
 ##########################################################
 ]]--
 local function LoadLogOMatic()
+	local toonClass = select(2,UnitClass("player"));
+	local r,g,b = RAID_CLASS_COLORS[toonClass].r, RAID_CLASS_COLORS[toonClass].g, RAID_CLASS_COLORS[toonClass].b
+	local hexString = ("|cff%02x%02x%02x"):format(r * 255, g * 255, b * 255)
 	if not SVLOG_Cache then SVLOG_Cache = {} end
-
 	SVLOG_Data = SVLOG_Data or {}
 	SVLOG_Data[realmKey] = SVLOG_Data[realmKey] or {}
 	SVLOG_Data[realmKey]["bags"] = SVLOG_Data[realmKey]["bags"] or {};
+	SVLOG_Data[realmKey]["info"] = SVLOG_Data[realmKey]["info"] or {};
+	SVLOG_Data[realmKey]["info"][nameKey] = hexString;
 	SVLOG_Data[realmKey]["bags"][nameKey] = SVLOG_Data[realmKey]["bags"][nameKey] or {};

 	LOG.stash = SVLOG_Data[realmKey]["bags"];
@@ -351,11 +323,19 @@ local function LoadLogOMatic()

 	LOG.chronicle = SVLOG_Data[realmKey]["quests"][nameKey];

-	NewHook(SuperVillain, "ResetProfile", ResetAllLogs);
+	NewHook(SuperVillain, "ResetAllUI", ResetAllLogs);

 	local uselog = SuperVillain.db.SVChat.saveChats;
 	if not SVLOG_Cache["chat"] then SVLOG_Cache["chat"] = {} end
-	LOG:BuildCachedInventory();
+
+	for alt,_ in pairs(SVLOG_Data[realmKey]["bags"]) do
+		for bag,items in pairs(SVLOG_Data[realmKey]["bags"][alt]) do
+			for id,amt in pairs(items) do
+				LOG.BagItemCache[id] = LOG.BagItemCache[id] or {}
+				LOG.BagItemCache[id][alt] = amt
+			end
+		end
+	end

 	--[[ OVERRIDE DEFAULT FUNCTIONS ]]--
 	if SuperVillain.db.SVBag.enable then
@@ -366,17 +346,12 @@ local function LoadLogOMatic()
 		end
 	end
 	if SuperVillain.db.SVTip.enable then
-		local TIP = SuperVillain.SVTip;
-		TIP["GameTooltip_OnTooltipSetItem"] = function(...) GameTooltip_OnTooltipSetItem(...) end
+		GameTooltip:HookScript("OnTooltipSetItem", GameTooltip_LogTooltipSetItem)
 	end

 	--[[ APPLY HOOKS ]]--
-	if SuperVillain.db.SVChat.enable and SuperVillain.db.SVChat.saveChats then
-		for _,event in pairs(LoggingEvents) do
-			CHAT:RegisterEvent(event, "LogCurrentChat")
-		end
-		CHAT:RegisterEvent("PLAYER_ENTERING_WORLD")
-	end
+	LOG:AppendChatFunctions()
+	NewHook(CHAT, "ReLoad", LOG.AppendChatFunctions);
 end

 SuperVillain.Registry:NewScript(LoadLogOMatic)