Quantcast

added modifier key control of tooltip display

Kevin Lyles [10-30-09 - 11:37]
added modifier key control of tooltip display
Filename
Upgrade.lua
WeightsWatcher.lua
defaults.lua
diff --git a/Upgrade.lua b/Upgrade.lua
index 6b52738..947159a 100644
--- a/Upgrade.lua
+++ b/Upgrade.lua
@@ -119,6 +119,15 @@ noop_down = [[
 	end
 ]]

+function upgradeAccountToHandleModifierKeys(vars)
+	if not vars.options.tooltip then
+		vars.options.tooltip = deepTableCopy(defaultVars.options.tooltip)
+	end
+
+	vars.dataMinorVersion = 5
+	return vars
+end
+
 function upgradeAccountToOrderedLists(vars)
 	local i, j = 1
 	local weightsListCopy = {}
@@ -259,6 +268,7 @@ upgradeAccountFunctions = {
 		[1] = function(vars) return upgradeAccountToNormalization(vars) end,
 		[2] = function(vars) return upgradeAccountToGemQuality(vars) end,
 		[3] = function(vars) return upgradeAccountToOrderedLists(vars) end,
+		[4] = function(vars) return upgradeAccountToHandleModifierKeys(vars) end,
 	},
 }

@@ -267,6 +277,7 @@ downgradeAccountFunctions = {
 		[2] = noop_down,
 		[3] = noop_down,
 		[4] = downgradeAccountFromOrderedLists,
+		[5] = noop_down,
 	},
 }

diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua
index 17c92cd..63f6452 100644
--- a/WeightsWatcher.lua
+++ b/WeightsWatcher.lua
@@ -192,6 +192,7 @@ end

 function WeightsWatcher:displayItemStats(tooltip, ttname)
 	local link, bareLink, itemType, stackSize, sockets, gemStats
+	local stat, value

 	_, link = tooltip:GetItem()
 	if link == nil then
@@ -202,34 +203,59 @@ function WeightsWatcher:displayItemStats(tooltip, ttname)
 	if (IsEquippableItem(link) and itemType ~= "Container" and itemType ~= "Quiver") or (itemType == "Gem" and stackSize == 1) or (itemType == "Consumable") or (itemType == "Recipe") then
 		bareLink = WeightsWatcher:cacheItemStats(link)

-		tooltip:AddLine("Current Weights:")
-		for _, class in ipairs(ww_charVars.activeWeights) do
-			if ww_vars.weightsList[class] then
-				for _, weight in pairs(ww_charVars.activeWeights[class]) do
-					if ww_vars.weightsList[class][weight] then
-						tooltip:AddDoubleLine("  " .. weight, string.format("%.3f", ww_weightCache[class][weight][link]))
-					end
-				end
-			end
-		end
-
-		_, sockets, _ = unpack(ww_bareItemCache[bareLink])
-
-		if #(sockets) > 0 then
-			tooltip:AddLine("Ideally Gemmed Weights:")
+		if keyDetectors[ww_vars.options.tooltip.showWeights]() then
+			tooltip:AddLine("Current Weights:")
 			for _, class in ipairs(ww_charVars.activeWeights) do
 				if ww_vars.weightsList[class] then
 					for _, weight in pairs(ww_charVars.activeWeights[class]) do
 						if ww_vars.weightsList[class][weight] then
-							tooltip:AddDoubleLine("  " .. weight, string.format("%.3f", ww_weightIdealCache[class][weight][bareLink].score))
-							gemStats = ww_weightIdealCache[class][weight][bareLink].gemStats
-							for _, stat in ipairs(gemStats) do
-								tooltip:AddLine("    Using " .. stat[2] .. " (" .. stat[1] .. ")")
+							tooltip:AddDoubleLine("  " .. weight, string.format("%.3f", ww_weightCache[class][weight][link]))
+						end
+					end
+				end
+			end
+
+			_, sockets, _ = unpack(ww_bareItemCache[bareLink])
+
+			if #(sockets) > 0 then
+				if keyDetectors[ww_vars.options.tooltip.showIdealWeights]() then
+					tooltip:AddLine("Ideally Gemmed Weights:")
+					for _, class in ipairs(ww_charVars.activeWeights) do
+						if ww_vars.weightsList[class] then
+							for _, weight in pairs(ww_charVars.activeWeights[class]) do
+								if ww_vars.weightsList[class][weight] then
+									tooltip:AddDoubleLine("  " .. weight, string.format("%.3f", ww_weightIdealCache[class][weight][bareLink].score))
+									if keyDetectors[ww_vars.options.tooltip.showIdealGems]() then
+										gemStats = ww_weightIdealCache[class][weight][bareLink].gemStats
+										for _, gem in ipairs(gemStats) do
+											tooltip:AddLine("    Using " .. gem[2] .. " (" .. gem[1] .. ")")
+											if keyDetectors[ww_vars.options.tooltip.showIdealGemStats]() then
+												for _, stat in ipairs(gem[4]) do
+													stat, value = unpack(stat)
+													tooltip:AddLine("      " .. stat .. ": " .. value)
+												end
+											end
+										end
+									end
+								end
 							end
 						end
 					end
+					if not keyDetectors[ww_vars.options.tooltip.showIdealGems]() then
+						if ww_vars.options.tooltip.showIdealGems then
+							tooltip:AddLine("<Press " .. ww_vars.options.tooltip.showIdealGems .. " to show ideal gems>")
+						end
+					elseif not keyDetectors[ww_vars.options.tooltip.showIdealGemStats]() then
+						if ww_vars.options.tooltip.showIdealGemStats then
+							tooltip:AddLine("<Press " .. ww_vars.options.tooltip.showIdealGemStats .. " to show ideal gem stats>")
+						end
+					end
+				elseif ww_vars.options.tooltip.showIdealWeights then
+					tooltip:AddLine("<Press " .. ww_vars.options.tooltip.showIdealWeights .. " to show ideal weights>")
 				end
 			end
+		elseif ww_vars.options.tooltip.showWeights then
+			tooltip:AddLine("<Press " .. ww_vars.options.tooltip.showWeights .. " to show weights>")
 		end
 		tooltip:Show()
 	end
diff --git a/defaults.lua b/defaults.lua
index bf8c853..6445e46 100644
--- a/defaults.lua
+++ b/defaults.lua
@@ -85,9 +85,23 @@ classNames = {
 	["WARRIOR"] = "Warrior",
 }

+keyDetectors = {
+	[true] = function() return true end,
+	[false] = function() return false end,
+	["LSHIFT"] = IsLeftShiftKeyDown,
+	["RSHIFT"] = IsRightShiftKeyDown,
+	["SHIFT"] = IsShiftKeyDown,
+	["LALT"] = IsLeftAltKeyDown,
+	["RALT"] = IsRightAltKeyDown,
+	["ALT"] = IsAltKeyDown,
+	["LCTRL"] = IsLeftControlKeyDown,
+	["RCTRL"] = IsRightControlKeyDown,
+	["CTRL"] = IsControlKeyDown,
+}
+
 defaultVars = {
 	dataMajorVersion = 0,
-	dataMinorVersion = 4,
+	dataMinorVersion = 5,
 	weightsList = {
 		[1] = "DEATHKNIGHT",
 		[2] = "DRUID",
@@ -458,6 +472,12 @@ defaultVars = {
 	options = {
 		normalizeWeights = true,
 		gemQualityLimit = 9,
+		tooltip = {
+			showWeights = true,
+			showIdealWeights = "SHIFT",
+			showIdealGems = "CTRL",
+			showIdealGemStats = true,
+		},
 	},
 }