diff --git a/Upgrade.lua b/Upgrade.lua index 4938d50..ef17c75 100644 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -135,6 +135,15 @@ function noop_major_up(vars) return vars end +function upgradeAccountToShowDifferences(vars) + if vars.options.tooltip.showDifferences == nil then + vars.options.tooltip.showDifferences = true + end + + vars.dataMinorVersion = 3 + return vars +end + function upgradeAccountToCorrectShowClassNames(vars) if vars.options.tooltip.showClassNames == nil then if vars.options.showClassNames == nil then @@ -515,6 +524,7 @@ upgradeAccountFunctions = { [1] = { [0] = function(vars) return upgradeAccountToBetterMetaEffectNames(vars) end, [1] = function(vars) return upgradeAccountToCorrectShowClassNames(vars) end, + [2] = function(vars) return upgradeAccountToShowDifferences(vars) end, }, } @@ -534,6 +544,7 @@ downgradeAccountFunctions = { [0] = downgradeAccountToDevelopment, [1] = downgradeAccountFromBetterMetaEffectNames, [2] = noop_down, + [3] = noop_down, }, } diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua index 242d327..0f4e7d9 100644 --- a/WeightsWatcher.lua +++ b/WeightsWatcher.lua @@ -291,7 +291,8 @@ end function WeightsWatcher:displayItemStats(tooltip, ttname) local link, bareLink, itemType, stackSize, sockets, gemStats - local stat, value, str + local stat, value, str, formatStr + local compareLink, compareBareLink, compareScore, compareLink2, compareBareLink2, compareScore2 local _, playerClass = UnitClass("player") _, link = tooltip:GetItem() @@ -303,6 +304,17 @@ 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 = splitItemLink(link) + if ttname == "GameTooltip" and ww_vars.options.tooltip.showDifferences then + _, compareLink = ShoppingTooltip1:GetItem() + if compareLink then + compareBareLink = splitItemLink(compareLink) + end + _, compareLink2 = ShoppingTooltip2:GetItem() + if compareLink2 then + compareBareLink2 = splitItemLink(compareLink2) + end + end + if keyDetectors[ww_vars.options.tooltip.showWeights]() then tooltip:AddLine("Current Weights:") for _, class in ipairs(ww_charVars.activeWeights) do @@ -313,7 +325,26 @@ function WeightsWatcher:displayItemStats(tooltip, ttname) if ww_vars.options.tooltip.showClassNames == "Always" or (ww_vars.options.tooltip.showClassNames == "Others" and class ~= playerClass) then str = str .. " - " .. classNames[class] end - tooltip:AddDoubleLine(str, string.format("%.3f", ww_weightCache[class][weight][link])) + if compareLink then + compareScore = ww_weightCache[class][weight][compareLink] + if compareLink2 then + compareScore2 = ww_weightCache[class][weight][compareLink2] + if compareScore2 < compareScore then + compareScore = compareScore2 + end + end + compareScore = ww_weightCache[class][weight][link] - compareScore + if compareScore < 0 then + formatStr = "%.3f (|cffff0000%+.3f|r)" + elseif compareScore > 0 then + formatStr = "%.3f (|cff00ff00%+.3f|r)" + else + formatStr = "%.3f (%+.3f)" + end + tooltip:AddDoubleLine(str, string.format(formatStr, ww_weightCache[class][weight][link], compareScore)) + else + tooltip:AddDoubleLine(str, string.format("%.3f", ww_weightCache[class][weight][link])) + end end end end @@ -332,7 +363,26 @@ function WeightsWatcher:displayItemStats(tooltip, ttname) if ww_vars.options.tooltip.showClassNames == "Always" or (ww_vars.options.tooltip.showClassNames == "Others" and class ~= playerClass) then str = str .. " - " .. classNames[class] end - tooltip:AddDoubleLine(str, string.format("%.3f", ww_weightIdealCache[class][weight][bareLink].score)) + if compareBareLink then + compareScore = ww_weightIdealCache[class][weight][compareBareLink].score + if compareBareLink2 then + compareScore2 = ww_weightIdealCache[class][weight][compareBareLink2].score + if compareScore2 < compareScore then + compareScore = compareScore2 + end + end + compareScore = ww_weightIdealCache[class][weight][bareLink].score - compareScore + if compareScore < 0 then + formatStr = "%.3f (|cffff0000%+.3f|r)" + elseif compareScore > 0 then + formatStr = "%.3f (|cff00ff00%+.3f|r)" + else + formatStr = "%.3f (%+.3f)" + end + tooltip:AddDoubleLine(str, string.format(formatStr, ww_weightIdealCache[class][weight][bareLink].score, compareScore)) + else + tooltip:AddDoubleLine(str, string.format("%.3f", ww_weightIdealCache[class][weight][bareLink].score)) + end if keyDetectors[ww_vars.options.tooltip.showIdealGems]() then gemStats = ww_weightIdealCache[class][weight][bareLink].gemStats for _, gem in ipairs(gemStats) do diff --git a/config.xml b/config.xml index e839cd5..0ca1c6f 100644 --- a/config.xml +++ b/config.xml @@ -406,6 +406,42 @@ </OnLoad> </Scripts> </Frame> + <CheckButton name="$parentShowDifference" parentKey="showDifference" inherits="UICheckButtonTemplate" text="Show differences to current gear"> + <Size> + <AbsDimension x="25" y="25"/> + </Size> + <Anchors> + <Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parentShowClassNames"/> + <Anchor point="LEFT"> + <Offset> + <AbsDimension x="5"/> + </Offset> + </Anchor> + </Anchors> + <Scripts> + <OnClick> + if self:GetChecked() then + ww_vars.options.tooltip.showDifferences = true + else + ww_vars.options.tooltip.showDifferences = false + end + </OnClick> + <OnEnter> + GameTooltip:SetOwner(self,"ANCHOR_RIGHT") + GameTooltip:AddLine("Shows the change in score compared to the currently equipped gear", 1, 1, 1) + GameTooltip:Show() + </OnEnter> + <OnLeave> + GameTooltip:Hide() + </OnLeave> + <OnLoad> + getglobal(self:GetName() .. "Text"):SetText(self:GetText()) + </OnLoad> + <OnShow> + self:SetChecked(ww_vars.options.tooltip.showDifferences) + </OnShow> + </Scripts> + </CheckButton> </Frames> </Frame> </Frames> diff --git a/defaults.lua b/defaults.lua index 9d21b7c..a1dbbd6 100644 --- a/defaults.lua +++ b/defaults.lua @@ -137,7 +137,7 @@ classNameOptions = { defaultVars = { dataMajorVersion = 1, - dataMinorVersion = 2, + dataMinorVersion = 3, weightsList = { [1] = "DEATHKNIGHT", [2] = "DRUID", @@ -541,6 +541,7 @@ defaultVars = { showIdealGems = "Control", showIdealGemStats = "Always", showClassNames = "Others", + showDifferences = true, }, }, }