Mercurial > wow > ouroloot
diff core.lua @ 148:113dd7c86222
Update how LoadOnDemand modules are treated for 6.0.
Blizzard API change, different return values. Adds finer-grained
handling. Users who don't want to see a module at all can disable the
module's "addon", and then later restore it from OL's option tab.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Wed, 07 Jan 2015 17:37:43 -0500 |
parents | e1a90e398231 |
children | df0ca8ed1aff |
line wrap: on
line diff
--- a/core.lua Tue Dec 30 20:26:41 2014 -0500 +++ b/core.lua Wed Jan 07 17:37:43 2015 -0500 @@ -140,6 +140,7 @@ }, ['forum_current'] = '[item] by name', ['display_disabled_LODs'] = false, + ['display_unusable_LODs'] = false, ['display_bcast_from'] = true, ['precache_history_uniques'] = false, ['chatty_on_remote_changes'] = false, @@ -432,7 +433,7 @@ local base = newproxy(true) getmetatable(base).__tostring = function(ud) return text_map[ud] end --@debug@ - -- auto collecting these tokens is an interesting micro-optimization but not yet + --[[ auto collecting these tokens is an interesting micro-optimization but not yet getmetatable(base).__index = { ['done'] = function (ud) text_map[ud] = nil @@ -441,7 +442,7 @@ } getmetatable(base).__gc = function(ud) print("Collecting hyperlink object <",tostring(ud),">") - end + end --]] --@end-debug@ -- TEXT will automatically be surrounded by brackets @@ -1049,7 +1050,9 @@ end self._cache_history_uniques = nil - self:_scan_LOD_modules() + -- This will be nil if there are no such modules. Used by the GUI + -- in _gui_add_disabled_LOD_tabs + self._disabled_LOD_modules = self:_scan_LOD_modules() self:_set_chatty_change_chatframe (opts.chatty_on_changes_frame, --[[silent_p=]]true) @@ -1315,16 +1318,18 @@ end worth_saving = false - for r,t in pairs(self.history_all) do if type(t) == 'table' then - if #t == 0 then - self.history_all[r] = nil - else - worth_saving = true - t.realm = nil - t.st = nil - t.byname = nil + for r,t in pairs(self.history_all) do + if type(t) == 'table' then + if #t == 0 then + self.history_all[r] = nil + else + worth_saving = true + t.realm = nil + t.st = nil + t.byname = nil + end end - end end + end if worth_saving then _G.OuroLootSV_hist = self.history_all _G.OuroLootSV_hist.HISTFORMAT = 4 @@ -1994,10 +1999,10 @@ return end self:Print("Restored previous data, but not in a raid", - "and 5-player mode not active. |cffff0505NOT tracking loot|r;", + "and 5-player mode is not active. |cffff0505NOT tracking loot|r;", "use 'enable' to activate loot tracking, or 'clear' to erase", "previous data, or 'help' to read about saved-texts commands.") - if #g_loot > 400 then + if #g_loot > 200 then self:Print("|cffff0505Crikey!|r You are carrying around a lot of", "stored loot data. You should seriously consider clearing it", "out, as some of the text generation routines can choke the", @@ -2081,18 +2086,38 @@ -- Check for plugins which haven't already been loaded, and add hooks for -- them. Credit to DBM for the approach here. function addon:_scan_LOD_modules() + local disabled for i = 1, GetNumAddOns() do if GetAddOnMetadata (i, "X-OuroLoot-Plugin") and IsAddOnLoadOnDemand(i) and not IsAddOnLoaded(i) then - local folder, _, _, enabled, _, reason = GetAddOnInfo(i) + -- 'loadflag' will be false for LOD addons + local folder, title, notes, loadflag, reason = GetAddOnInfo(i) + local enabled = GetAddOnEnableState (my_name, i) > 0 + local tabtitle = GetAddOnMetadata (i, "X-OuroLoot-Plugin") + local decision = 0 + self.dprint('flow', "scanning", folder, "loadflag is", loadflag, + "enabled is", enabled, "reason-why-not is", reason) if enabled or opts.display_disabled_LODs then - local tabtitle = GetAddOnMetadata (i, "X-OuroLoot-Plugin") self:_gui_add_LOD_tab (tabtitle, folder, i, enabled, reason) + decision = 1 + elseif (not enabled) and reason == 'DISABLED' then + disabled = disabled or flib.new() + local t = flib.new() + t.tabtitle = tabtitle + t.folder = folder + t.addon_index = i + disabled[#disabled+1] = t + decision = 2 + elseif opts.display_unusable_LODs then + self:_gui_add_LOD_tab (tabtitle, folder, i, enabled, reason) + decision = 3 end + self.dprint('flow', "...decision was", decision) end end + return disabled end -- Routines for printing changes made by remote users.