# HG changeset patch # User Farmbuyer of US-Kilrogg # Date 1343384592 0 # Node ID ba5ff82dcf199d3f68020cc758f0af5c6ca46628 # Parent 780b7e0eeeebb40e48d430afcb69cf2d659520db (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. diff -r 780b7e0eeeeb -r ba5ff82dcf19 .pkgmeta --- a/.pkgmeta Thu Jul 26 20:46:00 2012 +0000 +++ b/.pkgmeta Fri Jul 27 10:23:12 2012 +0000 @@ -11,10 +11,16 @@ # than waiting for bugfixes to get tagged libs/AceAddon-3.0: url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceAddon-3.0 + libs/AceConfig-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConfig-3.0 + libs/AceDBOptions-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDBOptions-3.0 + libs/AceDB-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceDB-3.0 + libs/AceConsole-3.0: + url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConsole-3.0 libs/AceEvent-3.0: url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceEvent-3.0 - libs/AceConsole-3.0: - url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConsole-3.0 libs/AceTimer-3.0: url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceTimer-3.0 libs/AceLocale-3.0: diff -r 780b7e0eeeeb -r ba5ff82dcf19 Ouro_Loot.toc --- a/Ouro_Loot.toc Thu Jul 26 20:46:00 2012 +0000 +++ b/Ouro_Loot.toc Fri Jul 27 10:23:12 2012 +0000 @@ -3,7 +3,7 @@ ## Version: @project-version@ ## Notes: Raid loot tracking and text generation ## Author: Farmbuyer of US-Kilrogg -## SavedVariables: OuroLootSV, OuroLootSV_saved, OuroLootSV_opts, OuroLootSV_hist, OuroLootSV_log +## SavedVariables: OuroLootSV, OuroLootSV_saved, OuroLootOptsDB, OuroLootSV_hist, OuroLootSV_log ## OptionalDeps: Ace3, DBM-Core, lib-st, LibFarmbuyer, tekDebug ## LoadManagers: AddonLoader ## X-LoadOn-Slash: /ouroloot, /ol @@ -21,6 +21,9 @@ libs\AceConsole-3.0\AceConsole-3.0.xml libs\AceGUI-3.0\AceGUI-3.0.xml libs\AceComm-3.0\AceComm-3.0.xml +libs\AceConfig-3.0\AceConfig-3.0.xml +libs\AceDB-3.0\AceDB-3.0.xml +libs\AceDBOptions-3.0\AceDBOptions-3.0.xml libs\lib-st\lib-st.xml #@end-no-lib-strip@ diff -r 780b7e0eeeeb -r ba5ff82dcf19 core.lua --- a/core.lua Thu Jul 26 20:46:00 2012 +0000 +++ b/core.lua Fri Jul 27 10:23:12 2012 +0000 @@ -102,9 +102,6 @@ OuroLootSV_saved = nil -- table of copies of saved texts, default nil; keys -- are numeric indices of tables, subkeys of those -- are name/forum/attend/date -OuroLootSV_opts = nil -- same as option_defaults until changed - -- autoshard: optional name of disenchanting player, default nil - -- threshold: optional loot threshold, default nil OuroLootSV_hist = nil OuroLootSV_log = {} @@ -138,6 +135,8 @@ ['precache_history_uniques'] = false, ['chatty_on_remote_changes'] = false, ['chatty_on_remote_changes_frame'] = 1, + ['itemfilter'] = {}, + ['itemvault'] = {}, } local virgin = "First time loaded? Hi! Use the /ouroloot command" .." to show the main display. You should probably browse the instructions" @@ -712,75 +711,33 @@ g_restore_p = OuroLootSV ~= nil self.dprint('flow', "oninit sets restore as", g_restore_p) - if _G.OuroLootSV_opts == nil then - _G.OuroLootSV_opts = {} + if _G.OuroLootOptsDB == nil then local vclick = self.format_hypertext ([[click here]], ITEM_QUALITY_UNCOMMON, 'help') self:ScheduleTimer(function(s) + for id in pairs(self.default_itemfilter) do + opts.itemfilter[id] = true + end + for id in pairs(self.default_itemvault) do + opts.itemvault[id] = true + end s:Print(virgin, tostring(vclick)) virgin = nil end,10,self) else virgin = nil end - opts = _G.OuroLootSV_opts + self.db = _G.LibStub("AceDB-3.0"):New("OuroLootOptsDB", + { profile = option_defaults } , --[[Default=]]true) + opts = self.db.profile + + --[[ local stored_datarev = opts.datarev or 14 for opt,default in pairs(option_defaults) do if opts[opt] == nil then opts[opt] = default end end - opts.datarev = option_defaults.datarev - - -- transition&remove old options - opts['forum_use_itemid'] = nil - if opts['forum_format'] then - opts.forum['Custom...'] = opts['forum_format'] - opts['forum_format'] = nil - end - if opts.forum['[url]'] then - opts.forum['[url] Wowhead'] = opts.forum['[url]'] - opts.forum['[url]'] = nil - opts.forum['[url] MMO/Wowstead'] = option_defaults.forum['[url] MMO/Wowstead'] - if opts['forum_current'] == '[url]' then - opts['forum_current'] = '[url] Wowhead' - end - end - if opts['register_slashloot'] then - self:Print[[The "/loot" command is no longer available, because it is used by Blizzard in MoP. You can toggle on other synonyms for "/ouroloot" in the Options tab.]] - end - opts['register_slashloot'] = nil - option_defaults = nil - if OuroLootSV then -- may not be the same as testing g_restore_p soon - if OuroLootSV.saved then - OuroLootSV_saved = OuroLootSV.saved; OuroLootSV.saved = nil - end - if OuroLootSV.threshold then - opts.threshold = OuroLootSV.threshold; OuroLootSV.threshold = nil - end - if OuroLootSV.autoshard then - opts.autoshard = OuroLootSV.autoshard; OuroLootSV.autoshard = nil - end - end - - -- get item filter table if needed - if opts.itemfilter == nil then - opts.itemfilter = self.default_itemfilter - else - -- remove old stuff that doesn't "drop" anymore - -- find some way of only doing this once - opts.itemfilter[29434] = nil -- Badge of Justice - opts.itemfilter[40752] = nil -- Emblem of Heroism - opts.itemfilter[40753] = nil -- Emblem of Valor - opts.itemfilter[45624] = nil -- Emblem of Conquest - opts.itemfilter[43228] = nil -- Stone Keeper's Shard - opts.itemfilter[47241] = nil -- Emblem of Triumph - opts.itemfilter[49426] = nil -- Emblem of Frost - end - self.default_itemfilter = nil - if opts.itemvault == nil then - opts.itemvault = self.default_itemvault - end - self.default_itemvault = nil + opts.datarev = option_defaults.datarev]] self:RegisterChatCommand("ouroloot", "OnSlash") if opts.register_slash_synonyms then @@ -825,65 +782,11 @@ -- Handle changes to the stored data format in stages from oldest to newest. -- bumpers[X] is responsible for updating from X to X+1. -- (This is turning into a lot of loops over the same table. Consolidate?) - if OuroLootSV then + if false and OuroLootSV then local dirty = false local bumpers = {} - bumpers[14] = function() - for i,e in ipairs(OuroLootSV) do - if e.bosskill then - e.bossname, e.bosskill = e.bosskill, nil - end - end - end - - bumpers[15] = function() - for i,e in ipairs(OuroLootSV) do - if e.kind == 'boss' then - e.maxsize, e.raiderlist, e.raidersnap = 0, nil, {} - end - end - OuroLootSV.raiders = OuroLootSV.raiders or {} - for name,r in pairs(OuroLootSV.raiders) do - r.subgroup = 0 - end - end - - bumpers[16] = function() - for i,e in ipairs(OuroLootSV) do - if e.kind == 'boss' then -- brown paper bag bugs - e.raidersnap = e.raidersnap or {} - e.maxsize = e.maxsize or 0 - end - end - end - - bumpers[17] = function() - for i,e in ipairs(OuroLootSV) do - if e.kind == 'loot' and e.is_heroic then - e.variant, e.is_heroic = 1, nil - -- Could try detecting any previous LFR loot here, but... gah - end - end - end - - bumpers[18] = bumpers[16] - -- In the not-very-many days between 16 and 19, I managed to break - -- the exact same data in the exact same way. At least they're - -- not actually running the same loop twice... probably... sigh. - - bumpers[19] = function() - local date = _G.date - for i,e in ipairs(OuroLootSV) do - if e.kind == 'loot' then - if e.history_unique then - e.unique, e.history_unique = e.history_unique, nil - end - if e.unique == nil or #e.unique == 0 then - e.unique = e.id .. e.person .. date("%Y/%m/%d %H:%M",e.stamp) - end - end - end - end + --bumpers[14] = function() start + --bumpers[19] = function() latest --[===[ local real = bumpers @@ -1120,7 +1023,7 @@ g_loot = {} -- not saved, just fooling PLAYER_LOGOUT tests _G.OuroLootSV = nil _G.OuroLootSV_saved = nil - _G.OuroLootSV_opts = nil + _G.OuroLootOptsDB = nil _G.OuroLootSV_hist = nil _G.OuroLootSV_log = nil _G.ReloadUI() diff -r 780b7e0eeeeb -r ba5ff82dcf19 gui.lua --- a/gui.lua Thu Jul 26 20:46:00 2012 +0000 +++ b/gui.lua Fri Jul 27 10:23:12 2012 +0000 @@ -117,6 +117,7 @@ :gsub("([^\n])\n([^\n])", "%1 %2") :gsub("|r\n\n", "|r\n") end + gui.markup = markup -- too useful to keep local end -- Working around this bug: @@ -355,7 +356,7 @@ return end - local display_bcast_from = OuroLootSV_opts.display_bcast_from + local display_bcast_from = self.db.profile.display_bcast_from -- XXX FIXME a major weakness here is that we're constantly replacing -- what's already been created. Lots of garbage. Trying to detect what -- actually needs to be replaced is even worse. We'll live with @@ -1414,7 +1415,7 @@ st_widget.head_offset = 15 st_widget.tail_offset = 0 - if OuroLootSV_opts.scroll_to_bottom then + if gui.opts.scroll_to_bottom then local scrollbar = _G[st.scrollframe:GetName().."ScrollBar"] if scrollbar then local _,max = scrollbar:GetMinMaxValues() @@ -1924,7 +1925,7 @@ if not status then addon:horrible_horrible_error(err) end - if OuroLootSV_opts.gui_noob then + if gui.opts.gui_noob then local tip = noob_tips[group] if type(tip) == 'function' then tip = tip() @@ -2001,6 +2002,7 @@ self:gui_init (g_loot, g_uniques) self:zero_printed_fenceposts() end + gui.opts = self.db.profile local display = AceGUI:Create("Frame") _d = display @@ -2393,7 +2395,7 @@ -- been real loot happening while the user was clicking and typing. local boss_index = addon._addBossEntry{ kind = 'boss', - bossname = (OuroLootSV_opts.snarky_boss and addon.boss_abbrev[data.name] or data.name) or data.name, + bossname = (gui.opts.snarky_boss and addon.boss_abbrev[data.name] or data.name) or data.name, reason = 'kill', instance = data.instance, duration = 0, diff -r 780b7e0eeeeb -r ba5ff82dcf19 options.lua --- 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]], diff -r 780b7e0eeeeb -r ba5ff82dcf19 text_tabs.lua --- a/text_tabs.lua Thu Jul 26 20:46:00 2012 +0000 +++ b/text_tabs.lua Fri Jul 27 10:23:12 2012 +0000 @@ -53,7 +53,7 @@ end local function forum (_, loot, last_printed, generated, cache) - local fmt = OuroLootSV_opts.forum[OuroLootSV_opts.forum_current] or "" + local fmt = addon.db.profile.forum[addon.db.profile.forum_current] or "" -- if it's capable of handling heroic items, consider them warned already forum_warned_heroic = forum_warned_heroic or fmt:find'%$I' @@ -103,10 +103,11 @@ end local function forum_specials (_,_, container, mkbutton) + local opts = addon.db.profile local map,current = {} - for label,format in pairs(OuroLootSV_opts.forum) do + for label,format in pairs(opts.forum) do table.insert(map,label) - if label == OuroLootSV_opts.forum_current then + if label == opts.forum_current then current = #map end end @@ -119,21 +120,21 @@ dd:SetList(map) dd:SetValue(current) dd:SetCallback("OnValueChanged", function(_dd,event,choice) - OuroLootSV_opts.forum_current = map[choice] + opts.forum_current = map[choice] forum_warned_heroic = nil editbox:SetDisabled(map[choice] ~= "Custom...") end) container:AddChild(dd) - editbox = mkbutton("EditBox", nil, OuroLootSV_opts.forum["Custom..."], + editbox = mkbutton("EditBox", nil, opts.forum["Custom..."], [[Format described in Help tab (Generated Text -> Forum Markup).]]) editbox:SetFullWidth(true) editbox:SetLabel("Custom:") editbox:SetCallback("OnEnterPressed", function(_e,event,value) - OuroLootSV_opts.forum["Custom..."] = value + opts.forum["Custom..."] = value _e.editbox:ClearFocus() end) - editbox:SetDisabled(OuroLootSV_opts.forum_current ~= "Custom...") + editbox:SetDisabled(opts.forum_current ~= "Custom...") container:AddChild(editbox) end diff -r 780b7e0eeeeb -r ba5ff82dcf19 verbage.lua --- a/verbage.lua Thu Jul 26 20:46:00 2012 +0000 +++ b/verbage.lua Fri Jul 27 10:23:12 2012 +0000 @@ -418,7 +418,8 @@ T.tips = [[ The |cffff8000[Ouro Loot]|r "legendary item" displayed at the start of all chat messages is a clickable link. Clicking opens the main display. An option -on the tab will cause a message to be printed after a boss kill, +on the tab will cause a message (and thus, the clickable link) to be +printed after a boss kill, mostly for lazy loot trackers who don't like typing slash commands to open windows. If you are broadcasting to somebody else who is tracking, you should probably be @@ -440,7 +441,7 @@ ]] T.tips_slashies = [[ -A field in the tab lets you use additional slash commands as a +A text field in the tab lets you use additional slash commands as a shortcut for . The author prefers , as an example. The default used to be until that became a builtin command in MoP.