Mercurial > wow > ouroloot
comparison 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 |
comparison
equal
deleted
inserted
replaced
147:e1a90e398231 | 148:113dd7c86222 |
---|---|
138 ['[item] by ID'] = '[item]$I[/item]$X - $T', | 138 ['[item] by ID'] = '[item]$I[/item]$X - $T', |
139 ['Custom...'] = '', | 139 ['Custom...'] = '', |
140 }, | 140 }, |
141 ['forum_current'] = '[item] by name', | 141 ['forum_current'] = '[item] by name', |
142 ['display_disabled_LODs'] = false, | 142 ['display_disabled_LODs'] = false, |
143 ['display_unusable_LODs'] = false, | |
143 ['display_bcast_from'] = true, | 144 ['display_bcast_from'] = true, |
144 ['precache_history_uniques'] = false, | 145 ['precache_history_uniques'] = false, |
145 ['chatty_on_remote_changes'] = false, | 146 ['chatty_on_remote_changes'] = false, |
146 ['chatty_on_local_changes'] = false, | 147 ['chatty_on_local_changes'] = false, |
147 ['chatty_on_changes_frame'] = 1, | 148 ['chatty_on_changes_frame'] = 1, |
430 local func_map = {} --_G.setmetatable({}, {__mode = 'k'}) | 431 local func_map = {} --_G.setmetatable({}, {__mode = 'k'}) |
431 local text_map = setmetatable({}, {__mode = 'v'}) | 432 local text_map = setmetatable({}, {__mode = 'v'}) |
432 local base = newproxy(true) | 433 local base = newproxy(true) |
433 getmetatable(base).__tostring = function(ud) return text_map[ud] end | 434 getmetatable(base).__tostring = function(ud) return text_map[ud] end |
434 --@debug@ | 435 --@debug@ |
435 -- auto collecting these tokens is an interesting micro-optimization but not yet | 436 --[[ auto collecting these tokens is an interesting micro-optimization but not yet |
436 getmetatable(base).__index = { | 437 getmetatable(base).__index = { |
437 ['done'] = function (ud) | 438 ['done'] = function (ud) |
438 text_map[ud] = nil | 439 text_map[ud] = nil |
439 func_map[ud] = nil | 440 func_map[ud] = nil |
440 end, | 441 end, |
441 } | 442 } |
442 getmetatable(base).__gc = function(ud) | 443 getmetatable(base).__gc = function(ud) |
443 print("Collecting hyperlink object <",tostring(ud),">") | 444 print("Collecting hyperlink object <",tostring(ud),">") |
444 end | 445 end --]] |
445 --@end-debug@ | 446 --@end-debug@ |
446 | 447 |
447 -- TEXT will automatically be surrounded by brackets | 448 -- TEXT will automatically be surrounded by brackets |
448 -- COLOR can be LE_ITEM_QUALITY_* or a formatting string ("|cff...") | 449 -- COLOR can be LE_ITEM_QUALITY_* or a formatting string ("|cff...") |
449 -- FUNC can be "MethodName", "tab_title", or a function | 450 -- FUNC can be "MethodName", "tab_title", or a function |
1047 if opts.precache_history_uniques and not InCombatLockdown() then | 1048 if opts.precache_history_uniques and not InCombatLockdown() then |
1048 self:_cache_history_uniques() | 1049 self:_cache_history_uniques() |
1049 end | 1050 end |
1050 self._cache_history_uniques = nil | 1051 self._cache_history_uniques = nil |
1051 | 1052 |
1052 self:_scan_LOD_modules() | 1053 -- This will be nil if there are no such modules. Used by the GUI |
1054 -- in _gui_add_disabled_LOD_tabs | |
1055 self._disabled_LOD_modules = self:_scan_LOD_modules() | |
1053 | 1056 |
1054 self:_set_chatty_change_chatframe (opts.chatty_on_changes_frame, --[[silent_p=]]true) | 1057 self:_set_chatty_change_chatframe (opts.chatty_on_changes_frame, --[[silent_p=]]true) |
1055 | 1058 |
1056 if self.debug.flow then self:Print"is in control-flow debug mode." end | 1059 if self.debug.flow then self:Print"is in control-flow debug mode." end |
1057 end | 1060 end |
1313 else | 1316 else |
1314 _G.OuroLootSV = nil | 1317 _G.OuroLootSV = nil |
1315 end | 1318 end |
1316 | 1319 |
1317 worth_saving = false | 1320 worth_saving = false |
1318 for r,t in pairs(self.history_all) do if type(t) == 'table' then | 1321 for r,t in pairs(self.history_all) do |
1319 if #t == 0 then | 1322 if type(t) == 'table' then |
1320 self.history_all[r] = nil | 1323 if #t == 0 then |
1321 else | 1324 self.history_all[r] = nil |
1322 worth_saving = true | 1325 else |
1323 t.realm = nil | 1326 worth_saving = true |
1324 t.st = nil | 1327 t.realm = nil |
1325 t.byname = nil | 1328 t.st = nil |
1326 end | 1329 t.byname = nil |
1327 end end | 1330 end |
1331 end | |
1332 end | |
1328 if worth_saving then | 1333 if worth_saving then |
1329 _G.OuroLootSV_hist = self.history_all | 1334 _G.OuroLootSV_hist = self.history_all |
1330 _G.OuroLootSV_hist.HISTFORMAT = 4 | 1335 _G.OuroLootSV_hist.HISTFORMAT = 4 |
1331 else | 1336 else |
1332 _G.OuroLootSV_hist = nil | 1337 _G.OuroLootSV_hist = nil |
1992 -- only generated text and raider join/leave data, not worth verbage | 1997 -- only generated text and raider join/leave data, not worth verbage |
1993 self.dprint('flow', ">:Activate restored generated texts, un-popping") | 1998 self.dprint('flow', ">:Activate restored generated texts, un-popping") |
1994 return | 1999 return |
1995 end | 2000 end |
1996 self:Print("Restored previous data, but not in a raid", | 2001 self:Print("Restored previous data, but not in a raid", |
1997 "and 5-player mode not active. |cffff0505NOT tracking loot|r;", | 2002 "and 5-player mode is not active. |cffff0505NOT tracking loot|r;", |
1998 "use 'enable' to activate loot tracking, or 'clear' to erase", | 2003 "use 'enable' to activate loot tracking, or 'clear' to erase", |
1999 "previous data, or 'help' to read about saved-texts commands.") | 2004 "previous data, or 'help' to read about saved-texts commands.") |
2000 if #g_loot > 400 then | 2005 if #g_loot > 200 then |
2001 self:Print("|cffff0505Crikey!|r You are carrying around a lot of", | 2006 self:Print("|cffff0505Crikey!|r You are carrying around a lot of", |
2002 "stored loot data. You should seriously consider clearing it", | 2007 "stored loot data. You should seriously consider clearing it", |
2003 "out, as some of the text generation routines can choke the", | 2008 "out, as some of the text generation routines can choke the", |
2004 "game client if they run for too long.") | 2009 "game client if they run for too long.") |
2005 end | 2010 end |
2079 end | 2084 end |
2080 | 2085 |
2081 -- Check for plugins which haven't already been loaded, and add hooks for | 2086 -- Check for plugins which haven't already been loaded, and add hooks for |
2082 -- them. Credit to DBM for the approach here. | 2087 -- them. Credit to DBM for the approach here. |
2083 function addon:_scan_LOD_modules() | 2088 function addon:_scan_LOD_modules() |
2089 local disabled | |
2084 for i = 1, GetNumAddOns() do | 2090 for i = 1, GetNumAddOns() do |
2085 if GetAddOnMetadata (i, "X-OuroLoot-Plugin") | 2091 if GetAddOnMetadata (i, "X-OuroLoot-Plugin") |
2086 and IsAddOnLoadOnDemand(i) | 2092 and IsAddOnLoadOnDemand(i) |
2087 and not IsAddOnLoaded(i) | 2093 and not IsAddOnLoaded(i) |
2088 then | 2094 then |
2089 local folder, _, _, enabled, _, reason = GetAddOnInfo(i) | 2095 -- 'loadflag' will be false for LOD addons |
2096 local folder, title, notes, loadflag, reason = GetAddOnInfo(i) | |
2097 local enabled = GetAddOnEnableState (my_name, i) > 0 | |
2098 local tabtitle = GetAddOnMetadata (i, "X-OuroLoot-Plugin") | |
2099 local decision = 0 | |
2100 self.dprint('flow', "scanning", folder, "loadflag is", loadflag, | |
2101 "enabled is", enabled, "reason-why-not is", reason) | |
2090 if enabled or opts.display_disabled_LODs then | 2102 if enabled or opts.display_disabled_LODs then |
2091 local tabtitle = GetAddOnMetadata (i, "X-OuroLoot-Plugin") | |
2092 self:_gui_add_LOD_tab (tabtitle, folder, i, enabled, reason) | 2103 self:_gui_add_LOD_tab (tabtitle, folder, i, enabled, reason) |
2093 end | 2104 decision = 1 |
2094 end | 2105 elseif (not enabled) and reason == 'DISABLED' then |
2095 end | 2106 disabled = disabled or flib.new() |
2107 local t = flib.new() | |
2108 t.tabtitle = tabtitle | |
2109 t.folder = folder | |
2110 t.addon_index = i | |
2111 disabled[#disabled+1] = t | |
2112 decision = 2 | |
2113 elseif opts.display_unusable_LODs then | |
2114 self:_gui_add_LOD_tab (tabtitle, folder, i, enabled, reason) | |
2115 decision = 3 | |
2116 end | |
2117 self.dprint('flow', "...decision was", decision) | |
2118 end | |
2119 end | |
2120 return disabled | |
2096 end | 2121 end |
2097 | 2122 |
2098 -- Routines for printing changes made by remote users. | 2123 -- Routines for printing changes made by remote users. |
2099 do | 2124 do |
2100 local change_chatframe | 2125 local change_chatframe |