Mercurial > wow > ouroloot
diff options.lua @ 97:ba5ff82dcf19
(First breaking change for MoP/3.0, incomplete transition.) Move generic user options to acedb. Remove older savedvar-upgrade code for a clean break. Add a profiles tab since it will be expected; changing profiles not yet implemented.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Fri, 27 Jul 2012 10:23:12 +0000 |
parents | 780b7e0eeeeb |
children | b5a55c69ef67 |
line wrap: on
line diff
--- a/options.lua Thu Jul 26 20:46:00 2012 +0000 +++ b/options.lua Fri Jul 27 10:23:12 2012 +0000 @@ -3,21 +3,29 @@ -- Don't bother recording any of this loot: addon.default_itemfilter = { + [52190] = true, -- Inferno Ruby + [52191] = true, -- Ocean Sapphire + [52192] = true, -- Dream Emerald + [52193] = true, -- Ember Topaz + [52194] = true, -- Demonseye + [52195] = true, -- Amberjewel + [52722] = true, -- Maelstrom Crystal + [71716] = true, -- Soothsayer's Runes -- could probably remove most of this now --- [29434] = true, -- Badge of Justice --- [40752] = true, -- Emblem of Heroism --- [40753] = true, -- Emblem of Valor --- [45624] = true, -- Emblem of Conquest --- [43228] = true, -- Stone Keeper's Shard --- [47241] = true, -- Emblem of Triumph --- [49426] = true, -- Emblem of Frost +-- [29434] = true, -- Badge of Justice +-- [40752] = true, -- Emblem of Heroism +-- [40753] = true, -- Emblem of Valor +-- [45624] = true, -- Emblem of Conquest +-- [43228] = true, -- Stone Keeper's Shard +-- [47241] = true, -- Emblem of Triumph +-- [49426] = true, -- Emblem of Frost } -- Mark these as straight to guild vault: addon.default_itemvault = { - [52078] = true, -- Chaos Orb - [69237] = true, -- Living Ember - [71998] = true, -- Essence of Destruction + [52078] = true, -- Chaos Orb + [69237] = true, -- Living Ember + [71998] = true, -- Essence of Destruction } local options_tree = { @@ -33,6 +41,10 @@ value = "filter", text = "Item Filters", }, + { + value = "profiles", + text = "Profiles", + }, }, }, { @@ -51,8 +63,6 @@ local gui = addon.gui_state_pointer local AceGUI = LibStub("AceGUI-3.0") local flib = LibStub("LibFarmbuyer") --- Local ref to OuroLootSV_opts, which may be reassigned after load. --- So instead this is updated when the tab is displayed. local opts local function mktoggle (opt, label, width, desc, opt_func) @@ -69,16 +79,20 @@ return w end +local function spacer (height) + local s = AceGUI:Create("Spacer") + s:SetFullWidth(true) + s:SetHeight(height) + return s +end + local function mktitle (txt) local t = AceGUI:Create("Label") t:SetFullWidth(true) t:SetColor (0.19, 0.68, 1) -- cff30adff t:SetFontObject(GameFontHighlightLarge) t:SetText(txt) - local s = AceGUI:Create("Spacer") - s:SetFullWidth(true) - s:SetHeight(20) - return t, s + return t, spacer(20) end local function adv_careful_OnTextChanged (ebox,event,value) @@ -160,7 +174,7 @@ [[See description under +Help -- Handy Tips -- Prescanning> for instructions.]]) container:AddChild(w) - w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w) + container:AddChild(spacer(10)) -- possible keybindings do local pair = AceGUI:Create("InlineGroup") @@ -228,7 +242,7 @@ end -- chatty disposition/assignment changes - w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w) + container:AddChild(spacer(10)) do local chatgroup = AceGUI:Create("InlineGroup") chatgroup:SetLayout("List") @@ -281,7 +295,7 @@ end -- boss mod selection - w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) container:AddChild(w) + container:AddChild(spacer(2)) do local list = {} local current @@ -310,6 +324,11 @@ --------------- do + local description = [[These control automatic handling of specific items when they are looted. "Item filter" is a list of items to ignore. "Vault items" is a list of items to mark as going to the guild vault (as if you had chosen "Mark as guild vault" from the Loot tab). + +Proper use of these lists can avoid a lot of noise and tedious clicking during or after a raid. You will probably need to add/remove entries as you advance between expansions and tiers.]] + local defaultstext = [[Clicking this button adds some reasonable defaults to your item lists. (This was done once automatically, the first time you loaded Ouro Loot, but you can delete them at any time.)]] + local warntext = [[At least one of the items in the filter list was not in your game client's cache. This is okay. Just wait a few seconds, display some other Ouro Loot tab or panel, and then display the Item Filters again.]] local cache_warn, cache_warned = false, false local function do_warning (cnt) @@ -326,6 +345,12 @@ controls.basic_filter = function (container) container:AddChildren(mktitle[[Item-Specific Special Handling]]) + local w = AceGUI:Create("Label") + w:SetFullWidth(true) + w:SetText(description) + container:AddChild(w) + container:AddChild(spacer(20)) + cache_warn, cache_warned = false, false local filterlist, vaultlist = {}, {} for id in pairs(opts.itemfilter) do @@ -346,8 +371,12 @@ cache_warn = true end end + -- This is so that the "add all defaults" button will never, ever, + -- trip over cache misses. + for id in pairs(addon.default_itemfilter) do GetItemInfo(id) end + for id in pairs(addon.default_itemvault) do GetItemInfo(id) end - local w = AceGUI:Create("EditBoxDropDown") + w = AceGUI:Create("EditBoxDropDown") w:SetRelativeWidth(0.4) w:SetText("Item filter") w:SetEditBoxTooltip("Link items which should no longer be tracked.") @@ -402,6 +431,53 @@ end) w:SetCallback("OnDropdownShown",do_warning) container:AddChild(w) + + local function MAYBE_ADD (destname, dest, id) + local name, link = GetItemInfo(id) + if not name then + addon:Print("> No data on ID %d, this may be a bug.",id) + return + end + if dest[id] then + addon:Print("> Skipping %s as it's already in '%s' list.", + link, destname) + else + dest[id] = true + addon:Print("> Added %s to '%s' list.", link, destname) + end + end + + container:AddChild(spacer(40)) + w = AceGUI:Create("Label") + w:SetFullWidth(true) + w:SetText(defaultstext) + container:AddChild(w) + w = AceGUI:Create("Button") + w:SetRelativeWidth(0.4) + w:SetText[[Add Default Entries]] + w:SetCallback("OnClick", function() + for id in pairs(addon.default_itemfilter) do + MAYBE_ADD ("filter", opts.itemfilter, id) + end + for id in pairs(addon.default_itemvault) do + MAYBE_ADD ("vault", opts.itemvault, id) + end + addon:redisplay() + end) + container:AddChild(w) + end +end + + +--------------- +do + local profiles + controls.basic_profiles = function (container) + if not profiles then + profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(addon.db) + LibStub("AceConfig-3.0"):RegisterOptionsTable("OuroLootProfiles", profiles) + end + LibStub("AceConfigDialog-3.0"):Open ("OuroLootProfiles", container) end end @@ -479,7 +555,7 @@ container:AddChild(simple) end - w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) container:AddChild(w) + container:AddChild(spacer(10)) w = mkbutton("EditBox", 'comm_ident', addon.ident, [[Set tracking to 'Disabled' in the top-right dropdown, then change this field (click Okay or press Enter).]]) @@ -537,7 +613,7 @@ end) container:AddChild(w) - w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(3) container:AddChild(w) + container:AddChild(spacer(3)) do local simple = AceGUI:Create("SimpleGroup") simple:SetLayout("Flow") @@ -583,7 +659,7 @@ -- Initial advanced panel function (unless debug mode is on during load, which -- means it was almost certainly hardcoded that way, which means it's probably -- me testing). -if false and addon.DEBUG_PRINT then +if addon.DEBUG_PRINT then controls.adv = adv_real else controls.adv = function (container) @@ -619,6 +695,12 @@ local status_for_scroll = {} local status_for_select = { treewidth = 160 } +local function preload() + for id in pairs(opts.itemfilter) do GetItemInfo(id) end + for id in pairs(opts.itemvault) do GetItemInfo(id) end + preload = nil +end + -- Clicking an entry on the left tree column. local opt_OnGroupSelected_func = function (treeg,event,category) local catfuncs = controls[category] @@ -648,7 +730,7 @@ -- Clicking the Options tab as a whole (tabs_OnGroupSelected["opt"]). local tabs_OGS = function (container, specials) - opts = OuroLootSV_opts + opts = gui.opts container:SetLayout("Fill") local left = AceGUI:Create("TreeGroup") @@ -687,6 +769,8 @@ end, 5, _w) end) specials:AddChild(w) + + if preload then preload() end end addon:register_tab_control_AT_END ("opt", [[Options]],