From f145746056f69b0d1eefcff98f1ac71b794dec87 Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Sun, 6 Mar 2011 07:49:31 -0600 Subject: [PATCH] Split config into separate windows in the Blizzard config UI --- Locales/enUS/base.lua | 48 ++-- config-calculation.xml | 132 ++++++++++ config-display.xml | 266 +++++++++++++++++++ config-gems.xml | 327 ++++++++++++++++++++++++ config.lua | 39 ++- config.xml | 667 +++++++----------------------------------------- weights.lua | 2 +- weights.xml | 4 +- widgets.xml | 20 +- 9 files changed, 887 insertions(+), 618 deletions(-) create mode 100644 config-calculation.xml create mode 100644 config-display.xml create mode 100644 config-enchants.xml create mode 100644 config-gems.xml diff --git a/Locales/enUS/base.lua b/Locales/enUS/base.lua index 066c3d8..5dc7ca4 100644 --- a/Locales/enUS/base.lua +++ b/Locales/enUS/base.lua @@ -16,12 +16,42 @@ L["HELP_TEXT_VERSION"] = " version displays version information" L["HELP_TEXT_HELP"] = " help displays this message" L["HELP_TEXT_BUGS"] = " Please report bugs at wowinterface.com or WeightsWatcher@gmail.com" L["config"] = "config" +L["calculation"] = "calculation" +L["display"] = "display" +L["enchants"] = "enchants" +L["gems"] = "gems" L["version"] = "version" L["weights"] = "weights" -- config.xml -L["CONFIG_TITLE"] = "WeightsWatcher Configuration" +L["CONF_WW_VER"] = "WeightsWatcher version: |cffffffff%s|r" +L["CONF_ACCT_VER"] = " Account data version: |cffffffff%d.%d|r" +L["CONF_CHAR_VER"] = " Character data version: |cffffffff%d.%d|r" +L["CONF_CONTACT"] = "Contact: |cffffffff%s|r" +L["CONF_WEBPAGE"] = "Web page: |cffffffff%s|r" +L["CONF_DESC"] = "WeightsWatcher provides an easy way to compare items based\non their actual stats, as well as suggesting item enhancements." +L["CONFIG_WEIGHTS"] = "Configure Weights" +L["CALC_NAME"] = "Calculation" 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_DEBUG"] = "Show parser debug information:" +L["HIDE_HINTS_TT"] = "Hides modifier key hints in tooltips" +L["HIDE_HINTS"] = "Hide tooltip hints" +L["SHOW_CLASS"] = "Show class names:" +L["SHOW_DIFF"] = "Show differences to current gear" +L["SHOW_DIFF_TT"] = "Shows the change in score compared to the currently equipped gear" +L["SHOW_ZEROES"] = "Show zero scores" +L["SHOW_ZEROES_TT"] = "Shows scores for weights that are zero (or negative)" +L["NORMALIZE"] = "Normalize weights" +L["NORMALIZE_TT"] = "Divides item scores by the total of all stats' values in that weight" +L["IDEAL_GEM_NAME"] = "Ideal Gems" +L["IDEAL_GEM_OPTS"] = "Ideal Gem Options" L["USE_UE_GEMS_TT"] = "Consider gems that are Unique-Equipped" L["USE_UE_GEMS"] = "Use Unique-Equipped Gems" L["USE_JC_GEMS_TT"] = "Consider gems that are Jewelcrafter-Only" @@ -43,22 +73,6 @@ 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["NORMALIZE"] = "Normalize weights" -L["NORMALIZE_TT"] = "Divides item scores by the total of all stats' values in that weight" -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_DEBUG"] = "Show parser debug information:" -L["HIDE_HINTS_TT"] = "Hides modifier key hints in tooltips" -L["HIDE_HINTS"] = "Hide tooltip hints" -L["SHOW_CLASS"] = "Show class names:" -L["SHOW_DIFF"] = "Show differences to current gear" -L["SHOW_DIFF_TT"] = "Shows the change in score compared to the currently equipped gear" -L["SHOW_ZEROES"] = "Show zero scores" -L["SHOW_ZEROES_TT"] = "Shows scores for weights that are zero (or negative)" -- weights.xml L["WEIGHTS_TITLE"] = "WeightsWatcher Weight Values" diff --git a/config-calculation.xml b/config-calculation.xml new file mode 100644 index 0000000..3b462e5 --- /dev/null +++ b/config-calculation.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:SetTextInsets(5, 5, 0, 0) + + + 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_weightCache = setmetatable({}, ww_weightCacheMetatable) + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + end + + + if ww_validateNumber(text, self:GetText()) then + self.number = self:GetText() + ww_vars.options.useEffects.uptimeRatio = self:GetNumber() / 100 + ww_weightCache = setmetatable({}, ww_weightCacheMetatable) + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + else + local cursorPosition = self:GetCursorPosition() - 1 + self:SetText(self.number) + self:SetCursorPosition(cursorPosition) + end + + + self:ClearFocus() + + + + + + + if ww_cooldownUseEffects then + self.label:SetText(ww_localization["IDEAL_USE_UPTIME"]) + else + self:SetParent(nil) + self:Hide() + end + + + + + + + self.title:SetText(ww_localization["CALC_OPTS"]) + self.name = ww_localization["CALC_NAME"] + self.parent = "WeightsWatcher" + self.default = function(...) + ww_vars.options.calculation = ww_deepTableCopy(ww_defaultVars.options.calculation) + ww_weightCache = setmetatable({}, ww_weightCacheMetatable) + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + end + self.refresh = function(...) + self.useEffectUptimeRatio.ratio:SetText(ww_vars.options.calculation.useEffectUptimeRatio * 100) + end + InterfaceOptions_AddCategory(self) + + + + diff --git a/config-display.xml b/config-display.xml new file mode 100644 index 0000000..8628a59 --- /dev/null +++ b/config-display.xml @@ -0,0 +1,266 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self.label:SetText(ww_localization["SHOW_WTS"]) + self.dropdown:SetText("showWeights") + + + + + + + + + + + + + + self.label:SetText(ww_localization["SHOW_IDEAL_WTS"]) + self.dropdown:SetText("showIdealWeights") + + + + + + + + + + + + + + self.label:SetText(ww_localization["SHOW_IDEAL_GEMS"]) + self.dropdown:SetText("showIdealGems") + + + + + + + + + + + + + + self.label:SetText(ww_localization["SHOW_ALT_IDEAL_GEMS"]) + self.dropdown:SetText("showAlternateGems") + + + + + + + + + + self.label:SetText(ww_localization["SHOW_IDEAL_GEM_STATS"]) + self.dropdown:SetText("showIdealGemStats") + + + + + + + + + + + + + + + self.label:SetText(ww_localization["SHOW_DEBUG"]) + self.dropdown:SetText("showDebugInfo") + + + + + + + + + + if self:GetChecked() then + ww_vars.options.tooltip.hideHints = true + else + ww_vars.options.tooltip.hideHints = false + end + + + self.shouldBeChecked = function() return ww_vars.options.tooltip.hideHints end + self.ttText = ww_localization["HIDE_HINTS_TT"] + self:SetText(ww_localization["HIDE_HINTS"]) + + + + + + + + + + + + + + + + + + + + + self.label:SetText(ww_localization["SHOW_CLASS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.tooltip.showZeroScores = true + else + ww_vars.options.tooltip.showZeroScores = false + end + + + self.shouldBeChecked = function() return ww_vars.options.tooltip.showZeroScores end + self.ttText = ww_localization["SHOW_ZEROES_TT"] + self:SetText(ww_localization["SHOW_ZEROES"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.tooltip.showDifferences = true + else + ww_vars.options.tooltip.showDifferences = false + end + + + self.shouldBeChecked = function() return ww_vars.options.tooltip.showDifferences end + self.ttText = ww_localization["SHOW_DIFF_TT"] + self:SetText(ww_localization["SHOW_DIFF"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.tooltip.normalizeWeights = true + else + ww_vars.options.tooltip.normalizeWeights = false + end + ww_weightCache = setmetatable({}, ww_weightCacheMetatable) + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.tooltip.normalizeWeights end + self.ttText = ww_localization["NORMALIZE_TT"] + self:SetText(ww_localization["NORMALIZE"]) + + + + + + + self.header:SetText(ww_localization["DISPLAY_OPTS"]) + self.name = ww_localization["DISPLAY_NAME"] + self.parent = "WeightsWatcher" + self.default = function() + ww_vars.options.tooltip = ww_defaultVars.options.tooltip + ww_weightCache = setmetatable({}, ww_weightCacheMetatable) + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + end + local checkBoxes = { + "hideHints", + "showZeroScores", + "showDifferences", + "normalizeWeights", + hideHints = self.hideTooltipHints, + showZeroScores = self.showZeroScores, + showDifferences = self.showDifference, + normalizeWeights = self.normalizeWeights, + } + self.refresh = function() + for _, option in ipairs(checkBoxes) do + local checkBox = checkBoxes[option] + checkBox:SetChecked(checkBox.shouldBeChecked()) + if checkBox.shouldBeEnabled then + if checkBox.shouldBeEnabled() then + checkBox:Enable() + else + checkBox:Disable() + end + end + end + end + InterfaceOptions_AddCategory(self) + + + + diff --git a/config-enchants.xml b/config-enchants.xml new file mode 100644 index 0000000..e69de29 diff --git a/config-gems.xml b/config-gems.xml new file mode 100644 index 0000000..3078f00 --- /dev/null +++ b/config-gems.xml @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self.label:SetText(ww_localization["MAX_GEM_QUAL"]) + self:SetBackdropColor(1, 0, 0, 0.5) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.types["Unique-Equipped"] = true + else + ww_vars.options.gems.types["Unique-Equipped"] = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.types["Unique-Equipped"] end + self.ttText = ww_localization["USE_UE_GEMS_TT"] + self:SetText(ww_localization["USE_UE_GEMS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.types["Jewelcrafter-Only"] = true + else + ww_vars.options.gems.types["Jewelcrafter-Only"] = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.types["Jewelcrafter-Only"] end + self.ttText = ww_localization["USE_JC_GEMS_TT"] + self:SetText(ww_localization["USE_JC_GEMS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.sources["Vendor"] = true + else + ww_vars.options.gems.sources["Vendor"] = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.sources["Vendor"] end + self.ttText = ww_localization["USE_VP_GEMS_TT"] + self:SetText(ww_localization["USE_VP_GEMS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.sources["PVP-Vendor"] = true + else + ww_vars.options.gems.sources["PVP-Vendor"] = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.sources["PVP-Vendor"] end + self.ttText = ww_localization["USE_PVPVP_GEMS_TT"] + self:SetText(ww_localization["USE_PVPVP_GEMS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.sources["Crafted"] = true + self:GetParent().useProcGems:Enable() + else + ww_vars.options.gems.sources["Crafted"] = false + self:GetParent().useProcGems:Disable() + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.sources["Crafted"] end + self.ttText = ww_localization["USE_PC_GEMS_TT"] + self:SetText(ww_localization["USE_PC_GEMS"]) + + + + + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.sources["Procced"] = true + else + ww_vars.options.gems.sources["Procced"] = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.sources["Procced"] end + self.shouldBeEnabled = function() return ww_vars.options.gems.sources["Crafted"] end + self.ttText = ww_localization["USE_P_GEMS_TT"] + self:SetText(ww_localization["USE_P_GEMS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.sources["Drop"] = true + else + ww_vars.options.gems.sources["Drop"] = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.sources["Drop"] end + self.ttText = ww_localization["USE_D_GEMS_TT"] + self:SetText(ww_localization["USE_D_GEMS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.sources["Quest"] = true + else + ww_vars.options.gems.sources["Quest"] = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.sources["Quest"] end + self.ttText = ww_localization["USE_QR_GEMS_TT"] + self:SetText(ww_localization["USE_QR_GEMS"]) + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.breakSocketColors = false + self:GetParent().alwaysObeySocketColors:Enable() + else + ww_vars.options.gems.breakSocketColors = true + self:GetParent().alwaysObeySocketColors:Disable() + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return not ww_vars.options.gems.breakSocketColors end + self.ttText = ww_localization["MATCH_SOCKET_TT"] + self:SetText(ww_localization["MATCH_SOCKET"]) + + + + + + + + + + + + + + if self:GetChecked() then + ww_vars.options.gems.neverBreakSocketColors = true + else + ww_vars.options.gems.neverBreakSocketColors = false + end + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + + + self.shouldBeChecked = function() return ww_vars.options.gems.neverBreakSocketColors end + self.shouldBeEnabled = function() return not ww_vars.options.gems.breakSocketColors end + self.ttText = ww_localization["ALWAYS_MATCH_SOCKET_TT"] + self:SetText(ww_localization["ALWAYS_MATCH_SOCKET"]) + + + + + + + self.header:SetText(ww_localization["IDEAL_GEM_OPTS"]) + self.name = ww_localization["IDEAL_GEM_NAME"] + self.parent = "WeightsWatcher" + self.default = function() + ww_vars.options.gems = ww_defaultVars.options.gems + ww_weightIdealCache = setmetatable({}, ww_weightIdealCacheMetatable) + end + local checkBoxes = { + "Unique-Equipped", + "Jewelcrafter-Only", + "Vendor", + "PVP-Vendor", + "Crafted", + "Procced", + "Drop", + "Quest", + "obeySocketColors", + "alwaysObeySocketColors", + ["Unique-Equipped"] = self.useUEGems, + ["Jewelcrafter-Only"] = self.useJCOnlyGems, + ["Vendor"] = self.useVendorGems, + ["PVP-Vendor"] = self.usePVPVendorGems, + ["Crafted"] = self.useCraftedGems, + ["Procced"] = self.useProcGems, + ["Drop"] = self.useDropGems, + ["Quest"] = self.useQuestGems, + ["obeySocketColors"] = self.obeySocketColors, + ["alwaysObeySocketColors"] = self.alwaysObeySocketColors, + } + self.refresh = function() + for _, option in ipairs(checkBoxes) do + local checkBox = checkBoxes[option] + checkBox:SetChecked(checkBox.shouldBeChecked()) + if checkBox.shouldBeEnabled then + if checkBox.shouldBeEnabled() then + checkBox:Enable() + else + checkBox:Disable() + end + end + end + end + InterfaceOptions_AddCategory(self) + + + + diff --git a/config.lua b/config.lua index 58c3d29..7dfdced 100644 --- a/config.lua +++ b/config.lua @@ -10,21 +10,40 @@ local function printHelp() print(L["HELP_TEXT_BUGS"]) end +local function showConfig(frame) + if frame:IsVisible() then + InterfaceOptionsFrameCancel:Click() + else + -- TODO: make this always open to the right section if possible + InterfaceOptionsFrame_OpenToCategory(frame) + end +end + function ww_commandHandler(msg) - if msg == L["config"] then - ww_weights:Hide() - -- TODO: make this work better with the confirmDiscardChanges dialog - if ww_weights:IsShown() then - return + if msg:find("^" .. L["config"]) then + local frame = ww_config + if msg:find(L["gems"]) then + frame = ww_configGemOptions + elseif msg:find(L["enchants"]) then + frame = ww_configEnchantOptions + elseif msg:find(L["display"]) then + frame = ww_configDisplayOptions + elseif msg:find(L["calculation"]) then + frame = ww_configCalculationOptions end - if ww_config:IsVisible() then - ww_config:Hide() + if ww_weights:IsVisible() then + ww_weights:SmartHide(function() + showConfig(frame) + end + ) else - ww_config:Show() + showConfig(frame) end elseif msg == L["weights"] then - ww_config:Hide() - if ww_config:IsShown() then + if InterfaceOptionsFrame:IsVisible() then + InterfaceOptionsFrameCancel:Click() + end + if InterfaceOptionsFrame:IsVisible() then return end if ww_weights:IsVisible() then diff --git a/config.xml b/config.xml index fe1f8b0..adca973 100644 --- a/config.xml +++ b/config.xml @@ -2,18 +2,14 @@ xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">