From 06a07b799289cd5574e51287533d62785b0b4d34 Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Fri, 20 Nov 2009 01:56:23 -0600 Subject: [PATCH] Added widgets to configure what is shown when in the tooltip Updated default vars Added upgrade function --- Upgrade.lua | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ WeightsWatcher.lua | 8 ++--- config.lua | 18 ++++++++++++ config.xml | 52 +++++++++++++++++++++++++++++++++ defaults.lua | 43 +++++++++++++++++---------- 5 files changed, 183 insertions(+), 20 deletions(-) diff --git a/Upgrade.lua b/Upgrade.lua index c8aae27..fcd29cc 100644 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -124,6 +124,86 @@ noop_down = [[ end ]] +function upgradeAccountToConfig(vars) + local table = vars.options.tooltip + local conversion = { + [true] = "Always", + [false] = "Never", + ["LSHIFT"] = "Left Shift", + ["RSHIFT"] = "Right Shift", + ["SHIFT"] = "Shift", + ["LALT"] = "Left Alt", + ["RALT"] = "Right Alt", + ["ALT"] = "Alt", + ["LCTRL"] = "Left Control", + ["RCTRL"] = "Right Control", + ["CTRL"] = "Control", + } + local keys = { + ["showIdealGemStats"] = true, + ["showIdealWeights"] = true, + ["showWeights"] = true, + ["showIdealGems"] = true, + } + + for key, value in pairs(table) do + if keys[key] then + if conversion[value] == nil then + if type(value) ~= "string" then + value = "type: " .. type(value) + end + print("WeightsWatcher: error: invalid value in tooltip options: " .. value) + return nil + end + table[key] = conversion[value] + end + end + + vars.dataMinorVersion = 10 + return vars +end + +downgradeAccountFromConfig = [[ + return function(vars) + local table = vars.options.tooltip + local conversion = { + ["Always"] = true, + ["Never"] = false, + ["Left Shift"] = "LSHIFT", + ["Right Shift"] = "RSHIFT", + ["Shift"] = "SHIFT", + ["Left Alt"] = "LALT", + ["Right Alt"] = "RALT", + ["Alt"] = "ALT", + ["Left Control"] = "LCTRL", + ["Right Control"] = "RCTRL", + ["Control"] = "CTRL", + } + local keys = { + ["showIdealGemStats"] = true, + ["showIdealWeights"] = true, + ["showWeights"] = true, + ["showIdealGems"] = true, + } + + for key, value in pairs(table) do + if keys[key] then + if conversion[value] == nil then + if type(value) ~= "string" then + value = "type: " .. type(value) + end + print("WeightsWatcher: error: invalid value in tooltip options: " .. value) + return nil + end + table[key] = conversion[value] + end + end + + vars.dataMinorVersion = 9 + return vars + end +]] + function upgradeAccountForceGemColors(vars) if vars.options.breakSocketColors == nil then vars.options.breakSocketColors = true @@ -308,6 +388,7 @@ upgradeAccountFunctions = { [6] = function(vars) return upgradeAccountShowClassNames(vars) end, [7] = function(vars) return upgradeAccountHideModKeyHints(vars) end, [8] = function(vars) return upgradeAccountForceGemColors(vars) end, + [9] = function(vars) return upgradeAccountToConfig(vars) end, }, } @@ -321,6 +402,7 @@ downgradeAccountFunctions = { [7] = noop_down, [8] = noop_down, [9] = noop_down, + [10] = downgradeAccountFromConfig, }, } diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua index 214110d..ec4199b 100644 --- a/WeightsWatcher.lua +++ b/WeightsWatcher.lua @@ -276,19 +276,19 @@ function WeightsWatcher:displayItemStats(tooltip, ttname) end end if not ww_vars.options.tooltip.hideHints and not keyDetectors[ww_vars.options.tooltip.showIdealGems]() then - if ww_vars.options.tooltip.showIdealGems then + if ww_vars.options.tooltip.showIdealGems ~= "Never" then tooltip:AddLine("") end elseif not ww_vars.options.tooltip.hideHints and not keyDetectors[ww_vars.options.tooltip.showIdealGemStats]() then - if ww_vars.options.tooltip.showIdealGemStats then + if ww_vars.options.tooltip.showIdealGemStats ~= "Never" then tooltip:AddLine("") end end - elseif not ww_vars.options.tooltip.hideHints and ww_vars.options.tooltip.showIdealWeights then + elseif not ww_vars.options.tooltip.hideHints and ww_vars.options.tooltip.showIdealWeights ~= "Never" then tooltip:AddLine("") end end - elseif not ww_vars.options.tooltip.hideHints and ww_vars.options.tooltip.showWeights then + elseif not ww_vars.options.tooltip.hideHints and ww_vars.options.tooltip.showWeights ~= "Never" then tooltip:AddLine("") end tooltip:Show() diff --git a/config.lua b/config.lua index 86f5a83..d32eda4 100644 --- a/config.lua +++ b/config.lua @@ -60,3 +60,21 @@ function GemQualityDropDownOnClick(choice, dropdown) ww_vars.options.gemQualityLimit = choice.value ww_weightIdealCache = {} end + +function ModifierKeyDropDownInitialize(dropdown) + local info = {} + + info.func = ModifierKeyDropDownOnClick + info.arg1 = dropdown + for _, value in ipairs(keyDetectors) do + info.text = value + info.value = value + info.checked = nil + UIDropDownMenu_AddButton(info) + end +end + +function ModifierKeyDropDownOnClick(choice, dropdown) + UIDropDownMenu_SetSelectedValue(dropdown, choice.value, false) + ww_vars.options.tooltip[dropdown:GetText()] = choice.value +end diff --git a/config.xml b/config.xml index f07d49f..cee1e11 100644 --- a/config.xml +++ b/config.xml @@ -1,6 +1,18 @@