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("<Press " .. ww_vars.options.tooltip.showIdealGems .. " to show ideal gems>") 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("<Press " .. ww_vars.options.tooltip.showIdealGemStats .. " to show ideal gem stats>") 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("<Press " .. ww_vars.options.tooltip.showIdealWeights .. " to show ideal weights>") 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("<Press " .. ww_vars.options.tooltip.showWeights .. " to show weights>") 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 @@ <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"> <Script file="config.lua"/> + <Button name="ww_modifierKeyDropDown" inherits="UIDropDownMenuTemplate" virtual="true"> + <Scripts> + <OnLoad> + UIDropDownMenu_JustifyText(self, "LEFT") + self:SetPoint("TOPLEFT", self:GetName() .. "Label", "BOTTOMLEFT", 0, -5) + </OnLoad> + <OnShow> + UIDropDownMenu_Initialize(self, ModifierKeyDropDownInitialize) + UIDropDownMenu_SetSelectedValue(self, ww_vars.options.tooltip[self:GetText()]) + </OnShow> + </Scripts> + </Button> <Frame name="ww_config" parent="UIParent" hidden="true" frameStrata="HIGH"> <Size> <AbsDimension x="600" y="600"/> @@ -27,6 +39,42 @@ </Anchor> </Anchors> </FontString> + <FontString name="$parentShowWeightsLabel" parentKey="showWeightsLabel" text="Show weights:" inherits="GameFontNormal"> + <Anchors> + <Anchor point="TOPLEFT"> + <Offset> + <AbsDimension x="5" y="-90"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <FontString name="$parentShowIdealWeightsLabel" parentKey="showIdealWeightsLabel" text="Show ideal weights:" inherits="GameFontNormal"> + <Anchors> + <Anchor point="TOPLEFT"> + <Offset> + <AbsDimension x="5" y="-140"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <FontString name="$parentShowIdealGemsLabel" parentKey="showIdealGemsLabel" text="Show ideal gems:" inherits="GameFontNormal"> + <Anchors> + <Anchor point="TOPLEFT"> + <Offset> + <AbsDimension x="5" y="-190"/> + </Offset> + </Anchor> + </Anchors> + </FontString> + <FontString name="$parentShowIdealGemStatsLabel" parentKey="showIdealGemStatsLabel" text="Show ideal gem stats:" inherits="GameFontNormal"> + <Anchors> + <Anchor point="TOPLEFT"> + <Offset> + <AbsDimension x="5" y="-240"/> + </Offset> + </Anchor> + </Anchors> + </FontString> </Layer> </Layers> <Frames> @@ -91,6 +139,10 @@ </OnShow> </Scripts> </Button> + <Button name="$parentShowWeights" parentKey="showWeights" inherits="ww_modifierKeyDropDown" text="showWeights"/> + <Button name="$parentShowIdealWeights" parentKey="showIdealWeights" inherits="ww_modifierKeyDropDown" text="showIdealWeights"/> + <Button name="$parentShowIdealGems" parentKey="showIdealGems" inherits="ww_modifierKeyDropDown" text="showIdealGems"/> + <Button name="$parentShowIdealGemStats" parentKey="showIdealGemStats" inherits="ww_modifierKeyDropDown" text="showIdealGemStats"/> </Frames> <Scripts> <OnLoad> diff --git a/defaults.lua b/defaults.lua index 16d9ec0..14cfd95 100644 --- a/defaults.lua +++ b/defaults.lua @@ -101,22 +101,33 @@ gemQualityNames = { } 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, + [1] = "Always", + [2] = "Never", + [3] = "Shift", + [4] = "Control", + [5] = "Alt", + [6] = "Left Shift", + [7] = "Right Shift", + [8] = "Left Control", + [9] = "Right Control", + [10] = "Left Alt", + [11] = "Right Alt", + ["Always"] = function() return true end, + ["Never"] = function() return false end, + ["Left Shift"] = IsLeftShiftKeyDown, + ["Right Shift"] = IsRightShiftKeyDown, + ["Shift"] = IsShiftKeyDown, + ["Left Alt"] = IsLeftAltKeyDown, + ["Right Alt"] = IsRightAltKeyDown, + ["Alt"] = IsAltKeyDown, + ["Left Control"] = IsLeftControlKeyDown, + ["Right Control"] = IsRightControlKeyDown, + ["Control"] = IsControlKeyDown, } defaultVars = { dataMajorVersion = 0, - dataMinorVersion = 9, + dataMinorVersion = 10, weightsList = { [1] = "DEATHKNIGHT", [2] = "DRUID", @@ -516,10 +527,10 @@ defaultVars = { showClassNames = "Others", tooltip = { hideHints = false, - showWeights = true, - showIdealWeights = "SHIFT", - showIdealGems = "CTRL", - showIdealGemStats = true, + showWeights = "Always", + showIdealWeights = "Shift", + showIdealGems = "Control", + showIdealGemStats = "Always", }, }, }