Mercurial > wow > ouroloot
changeset 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 |
files | core.lua gui.lua options.lua |
diffstat | 3 files changed, 76 insertions(+), 24 deletions(-) [+] |
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.
--- a/gui.lua Tue Dec 30 20:26:41 2014 -0500 +++ b/gui.lua Wed Jan 07 17:37:43 2015 -0500 @@ -300,7 +300,7 @@ else what.disabled = true gui.tabtexts[tabtitle] = what -- restore this for mouseovers - addon:Print("%s could not load (game client reason was '%s').", tabtitle, whynot) + addon:Print("%s could not load and will be disabled (game client reason was '%s').", tabtitle, whynot) DisableAddOn(addon_index) end dirty_tabs = true @@ -311,9 +311,9 @@ -- totally loadable, go for it LOAD() else - -- was disabled at addons menu + -- probably was disabled at addons menu StaticPopupDialogs["OUROL_LOD_DISABLED"] = flib.StaticPopup{ - text = tabtitle.." was disabled at the character selection screen. Do you want to enable it?", + text = [[%s is marked "%s". Do you want to enable and load it?]], button1 = YES, button2 = NO, OnAccept = function() @@ -327,7 +327,7 @@ StaticPopupDialogs["OUROL_LOD_DISABLED"] = nil end, } - StaticPopup_Show("OUROL_LOD_DISABLED") + StaticPopup_Show ("OUROL_LOD_DISABLED", tabtitle, _G['ADDON_' .. what.LOD_why_not]) end end @@ -347,6 +347,17 @@ dirty_tabs = true end + -- Called when the "include disabled plugins" option box is toggled on. + function addon:_gui_add_disabled_LOD_tabs() + while self._disabled_LOD_modules and #self._disabled_LOD_modules > 0 do + local t = tremove(self._disabled_LOD_modules) + self:_gui_add_LOD_tab (t.tabtitle, t.folder, t.addon_index, false, 'DISABLED') + end + + self._disabled_LOD_modules = nil + self._gui_add_disabled_LOD_tabs = flib.nullfunc + end + -- Registering truly arbitrary tab controls, not just text generators. -- (This is slightly out of place, but no more so than the LOD stuff.) -- The arguments are nearly the same as those of :register_text_generator
--- a/options.lua Tue Dec 30 20:26:41 2014 -0500 +++ b/options.lua Wed Jan 07 17:37:43 2015 -0500 @@ -175,10 +175,26 @@ [[Do not record anything in the History tab for players from other realms.]]) container:AddChild(w) - -- LOD plugins in all cases - w = mktoggle('display_disabled_LODs', "Include disabled plugins", stdw, - [[Show loadable plugins even if they've been disabled (and offer to enable them if clicked). Relog to take effect.]]) - container:AddChild(w) + do + -- LOD plugins unloadable for reasons other than disabling + local w_un = mktoggle('display_unusable_LODs', "Include unusable plugins", stdw, + [[Show plugins even if they are flagged for reasons besides simply being disabled. Relog to take effect.]]) + + -- LOD plugins disabled in the addons menu + w = mktoggle('display_disabled_LODs', "Include disabled plugins", stdw, + [[Show loadable plugins even if they've been disabled (and offer to enable them if clicked).]], + function (_w,_,value) + opts.display_disabled_LODs = value + w_un:SetDisabled(not opts.display_disabled_LODs) + addon.loot_clean = nil + addon.hist_clean = nil + addon:_gui_add_disabled_LOD_tabs() + end) + + w_un:SetDisabled(not opts.display_disabled_LODs) + container:AddChild(w) + container:AddChild(w_un) + end -- showing the "(from Rebroadcasterdude)" in the notes column w = mktoggle('display_bcast_from', "Show rebroadcasting player", stdw,