From 47f25866ffaaaa64d8e69f590bad30bc249d144e Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Fri, 30 Oct 2009 06:37:26 -0500 Subject: [PATCH] added modifier key control of tooltip display --- Upgrade.lua | 11 +++++++++ WeightsWatcher.lua | 64 ++++++++++++++++++++++++++++++++++++---------------- defaults.lua | 22 +++++++++++++++++- 3 files changed, 77 insertions(+), 20 deletions(-) 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("") + end + elseif not keyDetectors[ww_vars.options.tooltip.showIdealGemStats]() then + if ww_vars.options.tooltip.showIdealGemStats then + tooltip:AddLine("") + end + end + elseif ww_vars.options.tooltip.showIdealWeights then + tooltip:AddLine("") end end + elseif ww_vars.options.tooltip.showWeights then + tooltip:AddLine("") 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, + }, }, } -- 1.7.9.5