From 331e955dcc3065a3ba29aadcbc3aa8e599906feb Mon Sep 17 00:00:00 2001 From: pschifferer Date: Sat, 19 Dec 2009 23:10:07 +0000 Subject: [PATCH] Added a section to the options table that will appear in the Addons tab in the Interface. Added a global option to toggle whether the shopping list is auto-opened/closed. Added locale strings for the above changes. --- CauldronMain.lua | 64 +++++++++++++++++++++++++++++++++++++++++++--- Locale/Cauldron-enUS.lua | 4 +++ 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/CauldronMain.lua b/CauldronMain.lua index 0611689..f8313a4 100644 --- a/CauldronMain.lua +++ b/CauldronMain.lua @@ -24,6 +24,7 @@ Cauldron.libs = {}; -- Cauldron.libs.Abacus = LibStub("LibAbacus-3.0"); -- Cauldron.libs.PT = LibStub("LibPeriodicTable-3.1"); Cauldron.libs.GUI = LibStub("AceGUI-3.0"); +Cauldron.libs.AceConfigDialog = LibStub("AceConfigDialog-3.0"); -- logging Cauldron:SetLogLevel(Cauldron.logLevels.INFO); @@ -38,6 +39,25 @@ end CURRENT_TRADESKILL = ""; +local function GetProfileOption(info) + + if not Cauldron.db.global.options then + Cauldron.db.global.options = {}; + end + + return Cauldron.db.global.options[info.arg]; +end + +local function SetProfileOption(info, value) + + if not Cauldron.db.global.options then + Cauldron.db.global.options = {}; + end + + Cauldron.db.global.options[info.arg] = value; + +end + function Cauldron:OnInitialize() local globalDbDefaults = { profile = { @@ -59,6 +79,24 @@ function Cauldron:OnInitialize() handler = Cauldron, type = 'group', args = { + general = { + type = 'group', + cmdInline = true, + order = -1, + get = GetProfileOption, + set = SetProfileOption, + name = L["General"], + args = { + autoOpenShoppingList = { + type = 'toggle', + order = 1, + width = "double", + name = L["Auto-open shopping list?"], + desc = L["Automatically open the shopping list when the bank, guild bank, or a merchant window is opened."], + arg = "AutoOpenShoppingList", + }, + }, + }, shoppinglist = { name = L["Shopping list"], desc = L["Open shopping list window"], @@ -141,6 +179,15 @@ function Cauldron:OnInitialize() collectgarbage(); --]] + local config = Cauldron.libs.AceConfigDialog; + + -- add config UI to Blizzard interface + self.optionsFrames = {}; + -- The ordering here matters, it determines the order in the Blizzard Interface Options + self.optionsFrames.general = config:AddToBlizOptions("Cauldron", L["Cauldron"], nil, "general"); +-- self.optionsFrames.profile = config:AddToBlizOptions("Cauldron", L["Profiles"], L["Cauldron"], "profile"); + + --@alpha@ -- register test suite if WoWUnit then @@ -455,7 +502,9 @@ function Cauldron:OnMerchantShow() -- check if there's anything in the shopping list if CauldronShopping:ContainsItems(Cauldron.db.realm.shopping) then - Cauldron:ShowShoppingList(); + if Cauldron.db.global.options[AutoOpenShoppingList] then + Cauldron:ShowShoppingList(); + end if Cauldron.db.realm.userdata[Cauldron.vars.playername].options.autoBuy then CauldronShopping:AutoBuyShoppingItems(Cauldron.db.realm.shopping, Cauldron.vars.playername); @@ -467,7 +516,9 @@ end function Cauldron:OnMerchantClose() if not CauldronShopping:ContainsItems(Cauldron.db.realm.shopping) then - Cauldron:HideShoppingList(); + if Cauldron.db.global.options[AutoOpenShoppingList] then + Cauldron:HideShoppingList(); + end end end @@ -476,7 +527,9 @@ function Cauldron:OnBankOpened() -- check if there's anything in the shopping list if CauldronShopping:ContainsItems(Cauldron.db.realm.shopping) then - Cauldron:ShowShoppingList(); + if Cauldron.db.global.options[AutoOpenShoppingList] then + Cauldron:ShowShoppingList(); + end end end @@ -484,7 +537,9 @@ end function Cauldron:OnBankClosed() if not CauldronShopping:ContainsItems(Cauldron.db.realm.shopping) then - Cauldron:HideShoppingList(); + if Cauldron.db.global.options[AutoOpenShoppingList] then + Cauldron:HideShoppingList(); + end end end @@ -1323,3 +1378,4 @@ function Cauldron:Reset() self:Print("Reset complete."); end + diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua index 9ac6e4d..e6082c0 100644 --- a/Locale/Cauldron-enUS.lua +++ b/Locale/Cauldron-enUS.lua @@ -37,6 +37,10 @@ L["Queue All"] = true L["Process"] = true L["Clear Queue"] = true +L["General"] = true +L["Auto-open shopping list?"] = true +L["Automatically open the shopping list when the bank, guild bank, or a merchant window is opened."] = true + L["Cauldron had issues with some recipes for this profession."] = true L["Please close and re-open the %1$s window again to re-scan."] = true L["Rescanning recipe: %1$s..."] = true -- 1.7.9.5