From 654187ec40eed655c4bf8a1d84fa93d614bcb31e Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Mon, 28 Feb 2011 19:53:05 -0600 Subject: [PATCH] Changed to a unified set of options for item enhancement display Added enchant options Reworked the enhancement stat display --- EnchantIDs.lua | 50 ++++++---- Locales/enUS/base.lua | 33 +++++-- Upgrade.lua | 68 ++++++++++++++ WeightsWatcher.lua | 242 +++++++++++++++++++++++++++++++++-------------- config-calculation.xml | 4 +- config-display.xml | 64 ++++++++++--- config-enchants.xml | 243 ++++++++++++++++++++++++++++++++++++++++++++++++ config.lua | 63 +++++++++++++ defaults.lua | 46 +++++---- 9 files changed, 687 insertions(+), 126 deletions(-) diff --git a/EnchantIDs.lua b/EnchantIDs.lua index 966fd4a..4c06c75 100644 --- a/EnchantIDs.lua +++ b/EnchantIDs.lua @@ -11095,24 +11095,40 @@ local enchantItemMetatable = { table.insert(subslots, bareStats.nonStats.subslot) for _, subslot in ipairs(subslots) do for source, enchants in pairs(choices[slot][subslot] or {}) do - for boa, enchants in pairs(enchants) do - for faction, enchantIntervals in pairs(enchants) do - for _, enchants in ipairs(enchantIntervals.find(ww_vars.options.useBoa and boa and #(ww_reputations) or WeightsWatcher.getRepLevel(faction))) do - for profession, intervals in pairs(enchants) do - for _, intervals in ipairs(intervals.find(WeightsWatcher.getSkillLevel(profession))) do - for _, intervals in ipairs(intervals.find(bareStats.normalStats["item level"] or 1)) do - for _, interval in ipairs(intervals.find(WeightsWatcher.player.level)) do - for name, ids in pairs(interval) do - for id in pairs(ids) do - local score = WeightsWatcher.calculateWeight({}, { enchantStats = WeightsWatcher.enchantStats(id) }, tbl.weight) - if score > bestScore then - bestScore = score - bestEnchants = { [name] = { id } } - elseif score == bestScore then - if not bestEnchants[name] then - bestEnchants[name] = {} + if ww_vars.options.enchants.sources[source] then + for boa, enchants in pairs(enchants) do + for faction, enchantIntervals in pairs(enchants) do + local repLevel = WeightsWatcher.getRepLevel(faction) + if ww_vars.options.enchants.considerRep == "Any" then + repLevel = #(ww_reputations) + elseif ww_vars.options.enchants.considerRep == "Neutral or better" and repLevel >= 4 then + repLevel = #(ww_reputations) + elseif ww_vars.options.enchants.considerBoa and boa then + repLevel = #(ww_reputations) + end + for _, enchants in ipairs(enchantIntervals.find(repLevel)) do + for profession, intervals in pairs(enchants) do + local skillLevel = WeightsWatcher.getSkillLevel(profession) + if ww_vars.options.enchants.considerProfessions == "Any" then + skillLevel = 525 + elseif ww_vars.options.enchants.considerProfessions == "One or higher" and skillLevel > 0 then + skillLevel = 525 + end + for _, intervals in ipairs(intervals.find(skillLevel)) do + for _, intervals in ipairs(intervals.find(bareStats.normalStats["item level"] or 1)) do + for _, interval in ipairs(intervals.find(WeightsWatcher.player.level)) do + for name, ids in pairs(interval) do + for id in pairs(ids) do + local score = WeightsWatcher.calculateWeight({}, { enchantStats = WeightsWatcher.enchantStats(id) }, tbl.weight) + if score > bestScore then + bestScore = score + bestEnchants = { [name] = { id } } + elseif score == bestScore then + if not bestEnchants[name] then + bestEnchants[name] = {} + end + table.insert(bestEnchants[name], id) end - table.insert(bestEnchants[name], id) end end end diff --git a/Locales/enUS/base.lua b/Locales/enUS/base.lua index 5dc7ca4..ad27b5f 100644 --- a/Locales/enUS/base.lua +++ b/Locales/enUS/base.lua @@ -36,11 +36,12 @@ L["CALC_OPTS"] = "Calculation Options" L["DISPLAY_NAME"] = "Display" L["DISPLAY_OPTS"] = "Display Options" L["SHOW_WTS"] = "Show weights:" -L["SHOW_IDEAL_WTS"] = "Show ideally-gemmed weights:" -L["SHOW_IDEAL_GEMS"] = "Show ideal gems:" -L["SHOW_ALT_IDEAL_GEMS"] = "Show alternate ideal gems:" -L["SHOW_IDEAL_GEM_STATS"] = "Show ideal gem stats:" +L["SHOW_IDEAL_WTS"] = "Show ideally-enhanced weights:" +L["SHOW_IDEAL_ENHANCEMENTS"] = "Show ideal enhancements:" +L["SHOW_ALT_IDEAL_ENHANCEMENTS"] = "Show alternate ideal enhancements:" +L["SHOW_IDEAL_ENHANCEMENT_STATS"] = "Show ideal enhancement stats:" L["SHOW_DEBUG"] = "Show parser debug information:" +L["SHOW_ENHANCEMENTS_WHEN"] = "Show enhancements when:" L["HIDE_HINTS_TT"] = "Hides modifier key hints in tooltips" L["HIDE_HINTS"] = "Hide tooltip hints" L["SHOW_CLASS"] = "Show class names:" @@ -73,6 +74,20 @@ L["MATCH_SOCKET"] = "Obey socket colors" L["MATCH_SOCKET_TT"] = "Chooses ideal gems that obey their socket color (even if that gives a lower overall score)" L["ALWAYS_MATCH_SOCKET"] = "Even if the socket bonus is worthless" L["ALWAYS_MATCH_SOCKET_TT"] = "Forces ideal gems to obey their socket color (even if the socket bonus has a 0 or negative score for that weight)" +L["IDEAL_ENCHANT_NAME"] = "Ideal Enchants" +L["IDEAL_ENCHANT_OPTS"] = "Ideal Enchant Options" +L["USE_PC_ENCH_TT"] = "Consider enchants that are player crafted (usually but not always through Enchanting)" +L["USE_PC_ENCH"] = "Use Crafted Enchants" +L["USE_PVPVP_ENCH_TT"] = "Consider enchants that are purchasable with PVP tokens" +L["USE_PVPVP_ENCH"] = "Use PVP Vendor-Purchasable Enchants" +L["USE_QR_ENCH_TT"] = "Consider enchants that are quest rewards" +L["USE_QR_ENCH"] = "Use Quest Reqard Enchants" +L["USE_VP_ENCH_TT"] = "Consider enchants that are purchasable with gold" +L["USE_VP_ENCH"] = "Use Vendor-Purchasable Enchants" +L["USE_REP_ENCH"] = "Use enchants with rep requirements if my rep is:" +L["USE_BTA_ENCH_TT"] = "Use enchants that bind to account, regardless of rep" +L["USE_BTA_ENCH"] = "Use Bind to Account Enchants" +L["USE_PROF_ENCH"] = "Use enchants with profession reqs if my skill is:" -- weights.xml L["WEIGHTS_TITLE"] = "WeightsWatcher Weight Values" @@ -108,10 +123,10 @@ L["Gem Stats:"] = "Gem Stats:" L["Enchant Stats:"] = "Enchant Stats:" L[" Ideally-enhanced:"] = " Ideally-enhanced:" L["UNWEIGHTED_HINT"] = "|cffff0000* indicates unweighted effects|r (%d total)" -L["IDEAL_WTS_HINT"] = "" -L["IDEAL_GEMS_HINT"] = "" -L["IDEAL_GEM_STATS_HINT"] = "" -L["IDEAL_ALT_GEMS_HINT"] = "" +L["IDEAL_WTS_HINT"] = "" +L["IDEAL_ENHANCEMENTS_HINT"] = "" +L["ENHANCEMENT_STATS_HINT"] = "" +L["ALT_ENHANCEMENTS_HINT"] = "" L["WTS_HINT"] = "" L["DEBUG_HINT"] = "" L["WARN_UNREC_GEMID"] = "WeightsWatcher: Warning: Unrecognized GemId: %d" @@ -130,6 +145,8 @@ L["MULTIPLE_GEM_FORMAT"] = " (Option %d/%d) %s (%s)" L["SINGLE_GEM_FORMAT"] = " Using %s (%s)" L["MULTIPLE_ENCHANT_FORMAT"] = " (Option %d/%d) %s" L["SINGLE_ENCHANT_FORMAT"] = " Using %s" +L["ENHANCEMENT_STAT_FORMAT"] = " %d %s" +L["SOCKET_BONUS_FORMAT"] = " Socket Bonus" L["Container"] = "Container" L["Quiver"] = "Quiver" L["Gem"] = "Gem" diff --git a/Upgrade.lua b/Upgrade.lua index d48f75d..9f9ac36 100644 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -36,6 +36,70 @@ local function noop_major_up(vars) return vars end +local function upgradeAccountToEnchants(vars) + if not vars.options.calculation then + vars.options.calculation = {} + end + if not vars.options.calculation.useEffectUptimeRatio then + vars.options.calculation.useEffectUptimeRatio = vars.options.useEffects.uptimeRatio or ww_defaultVars.options.calculation.useEffectUptimeRatio + end + vars.options.useEffects = nil + + if vars.options.tooltip.showAlternateEnhancements == nil then + vars.options.tooltip.showAlternateEnhancements = vars.options.tooltip.showAlternateGems or ww_defaultVars.options.tooltip.showAlternateEnhancements + end + vars.options.tooltip.showAlternateGems = nil + if vars.options.tooltip.showEnhancements == nil then + vars.options.tooltip.showEnhancements = vars.options.tooltip.showIdealGems or ww_defaultVars.options.tooltip.showEnhancements + end + vars.options.tooltip.showIdealGems = nil + if vars.options.tooltip.showEnhancementStats == nil then + vars.options.tooltip.showEnhancementStats = vars.options.tooltip.showIdealGemStats or ww_defaultVars.options.tooltip.showEnhancementStats + end + vars.options.tooltip.showIdealGemStats = nil + if vars.options.tooltip.showEnhancementsWhen == nil then + vars.options.tooltip.showEnhancementsWhen = ww_defaultVars.options.tooltip.showEnhancementsWhen + end + + if not vars.options.enchants then + vars.options.enchants = ww_deepTableCopy(ww_defaultVars.options.enchants) + end + + vars.dataMajorVersion = 2 + vars.dataMinorVersion = 0 + + return vars +end + +local downgradeAccountFromEnchants = [[ + return function(vars) + if not vars.options.useEffects then + vars.options.useEffects = {} + end + if not vars.options.useEffects.uptimeRatio then + vars.options.useEffects.uptimeRatio = vars.options.calculation.useEffectUptimeRatio or ww_defaultVars.options.useEffects.uptimeRatio + end + + if vars.options.tooltip.showAlternateGems == nil then + vars.options.tooltip.showAlternateGems = vars.options.tooltip.showAlternateEnhancements or ww_defaultVars.options.tooltip.showAlternateGems + end + vars.options.tooltip.showAlternateEnhancements = nil + if vars.options.tooltip.showIdealGems == nil then + vars.options.tooltip.showIdealGems = vars.options.tooltip.showEnhancements or ww_defaultVars.options.tooltip.showIdealGems + end + vars.options.tooltip.showEnhancements = nil + if vars.options.tooltip.showIdealGemStats == nil then + vars.options.tooltip.showIdealGemStats = vars.options.tooltip.showEnhancementStats or ww_defaultVars.options.tooltip.showIdealGemStats + end + vars.options.tooltip.showEnhancementStats = nil + + vars.dataMajorVersion = 1 + vars.dataMinorVersion = 25 + + return vars + end +]] + local function UpgradeAccountToShowZeroScores(vars) if vars.options.tooltip.showZeroScores == nil then vars.options.tooltip.showZeroScores = false @@ -1040,6 +1104,7 @@ local upgradeAccountFunctions = { [22] = upgradeAccountToMeleeCrit, [23] = upgradeAccountToCataclysmGems, [24] = UpgradeAccountToShowZeroScores, + [25] = upgradeAccountToEnchants, }, } @@ -1083,6 +1148,9 @@ local downgradeAccountFunctions = { [24] = noop_down, [25] = noop_down, }, + [2] = { + [0] = downgradeAccountFromEnchants, + }, } local upgradeCharFunctions = { diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua index e919e52..6d2551a 100644 --- a/WeightsWatcher.lua +++ b/WeightsWatcher.lua @@ -26,7 +26,6 @@ local ww_bareItemCacheMetatable = { local ww_itemCacheMetatable = { __index = function(tbl, key) local gemStats, socketBonusActive - -- TODO: handle the enchant local bareLink, enchant, gems = splitLink(key) local sockets = ww_bareItemCache[bareLink].sockets @@ -132,6 +131,8 @@ local ww_weightIdealCacheWeightMetatable = { tbl[key] = { gemStats = gemStats, score = WeightsWatcher.calculateWeight(itemStats, {socketBonusActive = socketBonusActive, enchantStats = enchantStats, gemStats = gemStats}, tbl.weight), + socketBonusActive = socketBonusActive, + socketBonusScore = socketBonusWeight, } return tbl[key] end, @@ -830,63 +831,173 @@ local function addDebugInfo(tooltip, bareItemInfo, link) end end -local function addIdealGemInfo(tooltip, gemStats, showStats, showAlternates) - local alternatesExist = false - for _, gems in ipairs(gemStats) do +local function addDifferenceLine(tooltip, leftText, score, currentScore) + local difference = score - currentScore + tooltip:AddDoubleLine(leftText, string.format(colorizeDifferences(difference), score, difference)) +end + +local function addIdealGemInfo(tooltip, gemStats, showStats, showAlternates, currentGems, weightScale) + local alternatesExist, changesExist = false, false + for slot, gems in ipairs(gemStats.gems) do + local alreadyApplied = false for i, gem in ipairs(gems) do - if #(gems) > 1 then - tooltip:AddDoubleLine(string.format(L["MULTIPLE_GEM_FORMAT"], i, #(gems), ww_gemDisplayNames[gem[2]], ww_gemColorDisplayNames[gem[1]]), " ") - alternatesExist = true + if gem[2] == currentGems.gems[slot][1][2] then + alreadyApplied = true + break + end + end + + local forceDisplay = false + if ww_vars.options.tooltip.showEnhancementsWhen == "Always" then + forceDisplay = true + elseif ww_vars.options.tooltip.showEnhancementsWhen == "None applied" then + if currentGems.gems[slot][1][2] == "None" then + forceDisplay = true else - tooltip:AddDoubleLine(string.format(L["SINGLE_GEM_FORMAT"], ww_gemDisplayNames[gem[2]], ww_gemColorDisplayNames[gem[1]]), " ") + alreadyApplied = true end - if showStats then - for stat, value in pairs(gem[3]) do - tooltip:AddDoubleLine(string.format(L["TREBLY_INDENTED_STRING_FORMAT"], ww_statDisplayNames[stat]), value) + end + + if not alreadyApplied or forceDisplay then + changesExist = true + for i, gem in ipairs(gems) do + local score = WeightsWatcher.calculateWeight({}, { gemStats = {{{ [3] = gem[3] }}} }, weightScale) + local currentScore = WeightsWatcher.calculateWeight({}, { gemStats = {{{ [3] = currentGems.gems[slot][1][3] }}} }, weightScale) + if #(gems) > 1 then + addDifferenceLine(tooltip, string.format(L["MULTIPLE_GEM_FORMAT"], i, #(gems), ww_gemDisplayNames[gem[2]], ww_gemColorDisplayNames[gem[1]]), score, currentScore) + alternatesExist = true + else + addDifferenceLine(tooltip, string.format(L["SINGLE_GEM_FORMAT"], ww_gemDisplayNames[gem[2]], ww_gemColorDisplayNames[gem[1]]), score, currentScore) + end + if showStats then + for stat, value in pairs(gem[3]) do + local weight = WeightsWatcher.getWeight(stat, value, weightScale) + if ww_vars.options.tooltip.normalizeWeights then + weight = weight / ww_weightNormalizationCache[weightScale] + end + tooltip:AddDoubleLine(string.format(L["ENHANCEMENT_STAT_FORMAT"], value, ww_statDisplayNames[stat] or "Unlocalized: " .. stat), string.format("%.3f", weight)) + end + end + if not showAlternates then + break end - end - if not showAlternates then - break end end end - return alternatesExist + if changesExist and gemStats.socketBonusActive ~= currentGems.socketBonusActive then + addDifferenceLine(tooltip, L["SOCKET_BONUS_FORMAT"], gemStats.socketBonusActive and gemStats.socketBonusScore or 0, currentGems.socketBonusActive and currentGems.socketBonusScore or 0) + end + return alternatesExist, changesExist end -local function addIdealEnchantInfo(tooltip, enchants, showStats, showAlternates) +local function addIdealEnchantInfo(tooltip, enchants, showStats, showAlternates, currentEnchants, slot, weightScale) local count, displayCount = 0, 0 + local alreadyApplied = false + local enchantsExist = false for name, ids in pairs(enchants) do count = count + #(ids) + enchantsExist = true + if not alreadyApplied then + for _, slot in ipairs(ww_slotsToCheck[slot]) do + if currentEnchants.name then + if currentEnchants.name[slot] == name then + alreadyApplied = true + break + elseif type(currentEnchants.name[slot]) == "table" then + for _, curName in ipairs(currentEnchants.name[slot]) do + if curName == name then + alreadyApplied = true + break + end + end + if alreadyApplied then + break + end + end + end + end + end + end + if not enchantsExist then + alreadyApplied = true end - local alternatesExist = count > 1 - for name, ids in pairs(enchants) do - for i, id in pairs(ids) do - displayCount = displayCount + 1 - if alternatesExist then - tooltip:AddDoubleLine(string.format(L["MULTIPLE_ENCHANT_FORMAT"], displayCount, count, name), " ") - else - tooltip:AddDoubleLine(string.format(L["SINGLE_ENCHANT_FORMAT"], name), " ") - end - if showStats then - for stat, value in pairs(WeightsWatcher.enchantStats(id).stats) do - tooltip:AddDoubleLine(string.format(L["TREBLY_INDENTED_STRING_FORMAT"], ww_statDisplayNames[stat] or "Unlocalized: " .. stat), value) + local forceDisplay = false + if ww_vars.options.tooltip.showEnhancementsWhen == "Always" then + forceDisplay = true + elseif ww_vars.options.tooltip.showEnhancementsWhen == "None applied" then + if currentEnchants.name == nil then + forceDisplay = true + else + alreadyApplied = true + end + end + + local alternatesExist, changesExist = count > 1, false + + if not alreadyApplied or forceDisplay then + changesExist = true + for name, ids in pairs(enchants) do + for i, id in ipairs(ids) do + local enchantStats = WeightsWatcher.enchantStats(id) + displayCount = displayCount + 1 + local score = WeightsWatcher.calculateWeight({}, { enchantStats = enchantStats }, weightScale) + local currentScore = WeightsWatcher.calculateWeight({}, { enchantStats = currentEnchants }, weightScale) + if alternatesExist then + addDifferenceLine(tooltip, string.format(L["MULTIPLE_ENCHANT_FORMAT"], displayCount, count, name), score, currentScore) + else + addDifferenceLine(tooltip, string.format(L["SINGLE_ENCHANT_FORMAT"], name), score, currentScore) + end + if showStats then + for stat, value in pairs(enchantStats.stats) do + local weight = WeightsWatcher.getWeight(stat, value, weightScale) + if ww_vars.options.tooltip.normalizeWeights then + weight = weight / ww_weightNormalizationCache[weightScale] + end + tooltip:AddDoubleLine(string.format(L["ENHANCEMENT_STAT_FORMAT"], value, ww_statDisplayNames[stat] or "Unlocalized: " .. stat), string.format("%.3f", weight)) + end + end + if alternatesExist and not showAlternates then + break end end - if alternatesExist and not showAlternates then + if not showAlternates then break end end - if not showAlternates then - break - end end + return alternatesExist, changesExist +end + +local function addEnhancementInfo(tooltip, enhancements, showStats, showAlternates, currentEnhancements, slot, weightScale) + local alternatesExist, changesExist = false, false + if enhancements.gems then + local alternates, changes = addIdealGemInfo(tooltip, enhancements, showStats, showAlternates, currentEnhancements, weightScale) + if alternates then + alternatesExist = true + end + if changes then + changesExist = true + end + end + if enhancements.enchants then + local alternates, changes = addIdealEnchantInfo(tooltip, enhancements.enchants, showStats, showAlternates, currentEnhancements.enchants, slot, weightScale) + if alternates then + alternatesExist = true + end + if changes then + changesExist = true + end + end + if not changesExist then + tooltip:AddLine(string.format(L["DOUBLY_INDENTED_STRING_FORMAT"], "All enhancements already applied")) + end return alternatesExist end function WeightsWatcher.displayItemStats(tooltip, ttname) - local alternateGemsExist = false + local alternateEnhancementsExist = false local _, link = tooltip:GetItem() if link == nil then @@ -919,12 +1030,13 @@ function WeightsWatcher.displayItemStats(tooltip, ttname) local showWeights = ww_keyDetectors[ww_vars.options.tooltip.showWeights]() local showIdealWeights = ww_keyDetectors[ww_vars.options.tooltip.showIdealWeights]() - local showIdealGems = ww_keyDetectors[ww_vars.options.tooltip.showIdealGems]() - local showIdealGemStats = ww_keyDetectors[ww_vars.options.tooltip.showIdealGemStats]() - local showAlternateGems = ww_keyDetectors[ww_vars.options.tooltip.showAlternateGems]() + local showEnhancements = ww_keyDetectors[ww_vars.options.tooltip.showEnhancements]() + local showEnhancementStats = ww_keyDetectors[ww_vars.options.tooltip.showEnhancementStats]() + local showAlternateEnhancements = ww_keyDetectors[ww_vars.options.tooltip.showAlternateEnhancements]() local bareLink = splitLink(link) local bareItemInfo = ww_bareItemCache[bareLink] + local itemInfo = ww_itemCache[link] local compareMethod, compareLink, compareBareLink, compareLink2, compareBareLink2 = getCompareInfo(ttname, bareLink, bareItemInfo) @@ -935,34 +1047,27 @@ function WeightsWatcher.displayItemStats(tooltip, ttname) end if showWeights then + local currentEnhancements = { + gems = itemInfo.gemStats, + socketBonusActive = itemInfo.socketBonusActive, + enchants = itemInfo.enchantStats, + } 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 local currentScore = ww_weightCache[class][weight][link] if ww_vars.options.tooltip.showZeroScores or currentScore > 0 then - local compareScore, compareScore2, compareBareScore, compareBareScore2 + local compareScore, compareScore2 local str = weight if ww_vars.options.tooltip.showClassNames == "Always" or (ww_vars.options.tooltip.showClassNames == "Others" and class ~= WeightsWatcher.player.class) then str = string.format(L["WEIGHT_CLASS_FORMAT"], str, ww_classDisplayNames[class]) end if compareLink then compareScore = ww_weightCache[class][weight][compareLink] - if showIdealWeights and #(bareItemInfo.sockets) == 0 then - compareBareScore = ww_weightIdealCache[class][weight][compareBareLink].score - if compareScore < compareBareScore then - compareScore = compareBareScore - end - end end if compareLink2 then compareScore2 = ww_weightCache[class][weight][compareLink2] - if showIdealWeights and #(bareItemInfo.sockets) == 0 then - compareBareScore2 = ww_weightIdealCache[class][weight][compareBareLink2].score - if compareScore2 < compareBareScore2 then - compareScore2 = compareBareScore2 - end - end end compareScore = computeDifference(compareMethod, compareScore, compareScore2, currentScore) tooltip:AddDoubleLine(str, string.format(colorizeDifferences(compareScore), currentScore, compareScore)) @@ -977,16 +1082,15 @@ function WeightsWatcher.displayItemStats(tooltip, ttname) end compareScore = computeDifference(compareMethod, compareScore, compareScore2, currentScore) tooltip:AddDoubleLine(L[" Ideally-enhanced:"], string.format(colorizeDifferences(compareScore), currentScore, compareScore)) - if #(bareItemInfo.sockets) > 0 and showIdealGems then - local gemStats = ww_weightIdealCache[class][weight][bareLink].gemStats - if addIdealGemInfo(tooltip, gemStats, showIdealGemStats, showAlternateGems) then - alternateGemsExist = true - end - end - if showIdealGems then - local enchants = ww_bestEnchantsCache[class][weight][bareLink] - if addIdealEnchantInfo(tooltip, enchants, showIdealGemStats, showAlternateGems) then - alternateGemsExist = true + if showEnhancements then + local enhancements = { + gems = ww_weightIdealCache[class][weight][bareLink].gemStats, + socketBonusActive = ww_weightIdealCache[class][weight][bareLink].socketBonusActive, + socketBonusScore = ww_weightIdealCache[class][weight][bareLink].socketBonusScore, + enchants = ww_bestEnchantsCache[class][weight][bareLink], + } + if addEnhancementInfo(tooltip, enhancements, showEnhancementStats, showAlternateEnhancements, currentEnhancements, bareItemInfo.nonStats.slot, ww_vars.weightsList[class][weight]) then + alternateEnhancementsExist = true end end end @@ -1003,19 +1107,19 @@ function WeightsWatcher.displayItemStats(tooltip, ttname) if ww_vars.options.tooltip.showIdealWeights ~= "Never" then tooltip:AddLine(string.format(L["IDEAL_WTS_HINT"], ww_vars.options.tooltip.showIdealWeights)) end - elseif not showIdealGems then - if ww_vars.options.tooltip.showIdealGems ~= "Never" then - tooltip:AddLine(string.format(L["IDEAL_GEMS_HINT"], ww_vars.options.tooltip.showIdealGems)) + elseif not showEnhancements then + if ww_vars.options.tooltip.showEnhancements ~= "Never" then + tooltip:AddLine(string.format(L["IDEAL_ENHANCEMENTS_HINT"], ww_vars.options.tooltip.showEnhancements)) end else - if not showIdealGemStats then - if ww_vars.options.tooltip.showIdealGemStats ~= "Never" then - tooltip:AddLine(string.format(L["IDEAL_GEM_STATS_HINT"], ww_vars.options.tooltip.showIdealGemStats)) + if not showEnhancementStats then + if ww_vars.options.tooltip.showEnhancementStats ~= "Never" then + tooltip:AddLine(string.format(L["ENHANCEMENT_STATS_HINT"], ww_vars.options.tooltip.showEnhancementStats)) end end - if not showAlternateGems and alternateGemsExist then - if ww_vars.options.tooltip.showAlternateGems ~= "Never" then - tooltip:AddLine(string.format(L["IDEAL_ALT_GEMS_HINT"], ww_vars.options.tooltip.showAlternateGems)) + if not showAlternateEnhancements and alternateEnhancementsExist then + if ww_vars.options.tooltip.showAlternateEnhancements ~= "Never" then + tooltip:AddLine(string.format(L["ALT_ENHANCEMENTS_HINT"], ww_vars.options.tooltip.showAlternateEnhancements)) end end end @@ -1188,7 +1292,7 @@ function WeightsWatcher.calculateWeight(bareItemStats, itemStats, weightsScale) weight = weight + WeightsWatcher.getWeight(ww_englishStats[stat], value, weightsScale) end for _, useEffect in pairs(bareItemStats.useEffects or {}) do - local factor = useEffect.duration / useEffect.cooldown * ww_vars.options.useEffects.uptimeRatio + local factor = useEffect.duration / useEffect.cooldown * ww_vars.options.calculation.useEffectUptimeRatio for stat, value in pairs(useEffect.stats) do weight = weight + WeightsWatcher.getWeight(ww_englishStats[stat], value * factor, weightsScale) end diff --git a/config-calculation.xml b/config-calculation.xml index 3b462e5..0a7f30b 100644 --- a/config-calculation.xml +++ b/config-calculation.xml @@ -77,7 +77,7 @@ local text = self:GetText() if self:GetNumber() ~= 0 or text:match("^[0.]+$") or text == "" then self.number = text - ww_vars.options.useEffects.uptimeRatio = self:GetNumber() / 100 + ww_vars.options.calculation.useEffectUptimeRatio = self:GetNumber() / 100 ww_weightCache = setmetatable({}, ww_weightCacheMetatable) ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) end @@ -85,7 +85,7 @@ if ww_validateNumber(text, self:GetText()) then self.number = self:GetText() - ww_vars.options.useEffects.uptimeRatio = self:GetNumber() / 100 + ww_vars.options.calculation.useEffectUptimeRatio = self:GetNumber() / 100 ww_weightCache = setmetatable({}, ww_weightCacheMetatable) ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) else diff --git a/config-display.xml b/config-display.xml index 8628a59..f441719 100644 --- a/config-display.xml +++ b/config-display.xml @@ -52,7 +52,7 @@ - + @@ -62,14 +62,14 @@ - self.label:SetText(ww_localization["SHOW_IDEAL_GEMS"]) - self.dropdown:SetText("showIdealGems") + self.label:SetText(ww_localization["SHOW_IDEAL_ENHANCEMENTS"]) + self.dropdown:SetText("showEnhancements") - + - + @@ -77,25 +77,25 @@ - self.label:SetText(ww_localization["SHOW_ALT_IDEAL_GEMS"]) - self.dropdown:SetText("showAlternateGems") + self.label:SetText(ww_localization["SHOW_ALT_IDEAL_ENHANCEMENTS"]) + self.dropdown:SetText("showAlternateEnhancements") - + - + - self.label:SetText(ww_localization["SHOW_IDEAL_GEM_STATS"]) - self.dropdown:SetText("showIdealGemStats") + self.label:SetText(ww_localization["SHOW_IDEAL_ENHANCEMENT_STATS"]) + self.dropdown:SetText("showEnhancementStats") - + @@ -109,9 +109,47 @@ - + + + + + + + + + + + + + + + + self.label:SetText(ww_localization["SHOW_ENHANCEMENTS_WHEN"]) + + + + + + diff --git a/config-enchants.xml b/config-enchants.xml index e69de29..ff8fc24 100644 --- a/config-enchants.xml +++ b/config-enchants.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + if self:GetChecked() then + ww_vars.options.enchants.sources["Crafted"] = true + else + ww_vars.options.enchants.sources["Crafted"] = false + end + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.enchants.sources["Crafted"] end + self.ttText = ww_localization["USE_PC_ENCH_TT"] + self:SetText(ww_localization["USE_PC_ENCH"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.enchants.sources["PVP-Vendor"] = true + else + ww_vars.options.enchants.sources["PVP-Vendor"] = false + end + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.enchants.sources["PVP-Vendor"] end + self.ttText = ww_localization["USE_PVPVP_ENCH_TT"] + self:SetText(ww_localization["USE_PVPVP_ENCH"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.enchants.sources["Quest"] = true + else + ww_vars.options.enchants.sources["Quest"] = false + end + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.enchants.sources["Quest"] end + self.ttText = ww_localization["USE_QR_ENCH_TT"] + self:SetText(ww_localization["USE_QR_ENCH"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.enchants.sources["Vendor"] = true + else + ww_vars.options.enchants.sources["Vendor"] = false + end + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.enchants.sources["Vendor"] end + self.ttText = ww_localization["USE_VP_ENCH_TT"] + self:SetText(ww_localization["USE_VP_ENCH"]) + + + + + + + + + + + + + + + + + + + + + self.label:SetText(ww_localization["USE_REP_ENCH"]) + + + + + + + + + + + + + + if self:GetChecked() then + ww_vars.options.enchants.considerBoa = true + else + ww_vars.options.enchants.considerBoa = false + end + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.enchants.considerBoa end + self.ttText = ww_localization["USE_BTA_ENCH_TT"] + self:SetText(ww_localization["USE_BTA_ENCH"]) + + + + + + + + + + + + + + + + + + + + + self.label:SetText(ww_localization["USE_PROF_ENCH"]) + + + + + + + self.header:SetText(ww_localization["IDEAL_ENCHANT_OPTS"]) + self.name = ww_localization["IDEAL_ENCHANT_NAME"] + self.parent = "WeightsWatcher" + self.default = function() + ww_vars.options.enchants = ww_defaultVars.options.enchants + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + end + local checkBoxes = { + "Crafted", + "PVP-Vendor", + "Quest", + "Vendor", + "considerBoa", + ["Vendor"] = self.useVendorEnchants, + ["PVP-Vendor"] = self.usePVPVendorEnchants, + ["Crafted"] = self.useCraftedEnchants, + ["Quest"] = self.useQuestEnchants, + ["considerBoa"] = self.considerBoa, + } + self.refresh = function() + for _, option in ipairs(checkBoxes) do + local checkBox = checkBoxes[option] + checkBox:SetChecked(checkBox.shouldBeChecked()) + end + end + InterfaceOptions_AddCategory(self) + + + + diff --git a/config.lua b/config.lua index 7dfdced..3c7c4ae 100644 --- a/config.lua +++ b/config.lua @@ -114,3 +114,66 @@ function ww_ShowClassNameDropDownInitialize(dropdown) UIDropDownMenu_AddButton(info) end end + +local function RepOptionsDropDownOnClick(choice, dropdown) + UIDropDownMenu_SetSelectedValue(dropdown, choice.value, false) + ww_vars.options.enchants.considerRep = choice.value + if choice.value == "Any" then + ww_configEnchantOptions.considerBoa:Disable() + else + ww_configEnchantOptions.considerBoa:Enable() + end + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) +end + +function ww_RepOptionsDropDownInitialize(dropdown) + local info = {} + + info.func = RepOptionsDropDownOnClick + info.arg1 = dropdown + for _, value in ipairs({ "High enough", "Neutral or better", "Any" }) do + info.text = value + info.value = value + info.checked = nil + UIDropDownMenu_AddButton(info) + end +end + +local function ProfessionOptionsDropDownOnClick(choice, dropdown) + UIDropDownMenu_SetSelectedValue(dropdown, choice.value, false) + ww_vars.options.enchants.considerProfessions = choice.value + WeightsWatcher.ResetEnchantCache() + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) +end + +function ww_ProfessionOptionsDropDownInitialize(dropdown) + local info = {} + + info.func = ProfessionOptionsDropDownOnClick + info.arg1 = dropdown + for _, value in ipairs({ "High enough", "One or higher", "Any" }) do + info.text = value + info.value = value + info.checked = nil + UIDropDownMenu_AddButton(info) + end +end + +local function ShowEnhancementsWhenDropDownOnClick(choice, dropdown) + UIDropDownMenu_SetSelectedValue(dropdown, choice.value, false) + ww_vars.options.tooltip.showEnhancementsWhen = choice.value +end + +function ww_ShowEnhancementsWhenDropDownInitialize(dropdown) + local info = {} + + info.func = ShowEnhancementsWhenDropDownOnClick + info.arg1 = dropdown + for _, value in ipairs({ "None applied", "Non-ideal applied", "Always" }) do + info.text = value + info.value = value + info.checked = nil + UIDropDownMenu_AddButton(info) + end +end diff --git a/defaults.lua b/defaults.lua index 8c5d6b5..96860f3 100644 --- a/defaults.lua +++ b/defaults.lua @@ -187,8 +187,8 @@ ww_classNameOptions = { } ww_defaultVars = { - dataMajorVersion = 1, - dataMinorVersion = 25, + dataMajorVersion = 2, + dataMinorVersion = 0, weightsList = { "DEATHKNIGHT", "DRUID", @@ -679,40 +679,52 @@ ww_defaultVars = { }, }, options = { + calculation = { + useEffectUptimeRatio = 0.8, + }, + enchants = { + considerBoa = true, + considerRep = "High enough", + considerProfessions = "High enough", + sources = { + ["Crafted"] = true, + ["PVP-Vendor"] = false, + ["Quest"] = false, + ["Vendor"] = true, + }, + }, gems = { - qualityLimit = 10, breakSocketColors = true, neverBreakSocketColors = false, - types = { - ["Normal"] = true, - ["Unique-Equipped"] = false, - ["Jewelcrafter-Only"] = false, - }, + qualityLimit = 10, sources = { - ["Vendor"] = true, - ["PVP-Vendor"] = false, ["Crafted"] = true, - ["Procced"] = true, ["Drop"] = false, + ["Procced"] = true, + ["PVP-Vendor"] = false, ["Quest"] = false, + ["Vendor"] = true, + }, + types = { + ["Jewelcrafter-Only"] = false, + ["Normal"] = true, + ["Unique-Equipped"] = false, }, }, tooltip = { hideHints = false, normalizeWeights = true, - showAlternateGems = "Alt", + showAlternateEnhancements = "Alt", showClassNames = "Other Classes", showDebugInfo = "Never", showDifferences = true, - showIdealGems = "Control", - showIdealGemStats = "Always", + showEnhancements = "Control", + showEnhancementStats = "Always", + showEnhancementsWhen = "Non-ideal applied", showIdealWeights = "Shift", showWeights = "Always", showZeroScores = false, }, - useEffects = { - uptimeRatio = 0.8, - } }, } -- 1.7.9.5