Mercurial > wow > ouroloot
comparison core.lua @ 58:59718ec80610
Consolidate some common code out of modules.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Tue, 17 Apr 2012 06:26:11 +0000 |
| parents | 81d5449621f8 |
| children | 99ab21f0755f |
comparison
equal
deleted
inserted
replaced
| 57:81d5449621f8 | 58:59718ec80610 |
|---|---|
| 660 self:_scan_LOD_modules() | 660 self:_scan_LOD_modules() |
| 661 | 661 |
| 662 if self.debug.flow then self:Print"is in control-flow debug mode." end | 662 if self.debug.flow then self:Print"is in control-flow debug mode." end |
| 663 end | 663 end |
| 664 --function addon:OnDisable() end | 664 --function addon:OnDisable() end |
| 665 | |
| 666 do | |
| 667 local prototype = {} | |
| 668 local function module_OnEnable (plugin) | |
| 669 if plugin.option_defaults then | |
| 670 local SVname = 'OuroLoot'..plugin:GetName()..'_opts' | |
| 671 if not _G[SVname] then | |
| 672 _G[SVname] = {} | |
| 673 if type(plugin.OnFirstTime) == 'function' then | |
| 674 plugin:OnFirstTime() | |
| 675 end | |
| 676 end | |
| 677 plugin.opts = _G[SVname] | |
| 678 for option,default in pairs(plugin.option_defaults) do | |
| 679 if plugin.opts[option] == nil then | |
| 680 plugin.opts[option] = default | |
| 681 end | |
| 682 end | |
| 683 plugin.option_defaults = nil | |
| 684 end | |
| 685 end | |
| 686 | |
| 687 -- By default, no plugins. First plugin to use the special registration | |
| 688 -- sets up code for any subsequent plugins. | |
| 689 addon.is_plugin = flib.nullfunc | |
| 690 local function module_rtg (plugin, text_type, ...) | |
| 691 local registry = { [text_type]=plugin } | |
| 692 addon.is_plugin = function(a,t) return registry[t] end | |
| 693 prototype.register_text_generator = function(p,t,...) | |
| 694 registry[t] = p | |
| 695 return addon:register_text_generator(t,...) | |
| 696 end | |
| 697 return addon:register_text_generator(text_type,...) | |
| 698 end | |
| 699 | |
| 700 prototype.OnEnable = module_OnEnable | |
| 701 prototype.default_OnEnable = module_OnEnable | |
| 702 prototype.register_text_generator = module_rtg | |
| 703 | |
| 704 addon:SetDefaultModuleLibraries("AceConsole-3.0") | |
| 705 addon:SetDefaultModulePrototype(prototype) | |
| 706 -- Fires before the plugin's own OnEnable (inherited or otherwise). | |
| 707 --function addon:OnModuleCreated (plugin) | |
| 708 -- print("created plugin", plugin:GetName()) | |
| 709 --end | |
| 710 end | |
| 665 | 711 |
| 666 | 712 |
| 667 ------ Event handlers | 713 ------ Event handlers |
| 668 function addon:_clear_SVs() | 714 function addon:_clear_SVs() |
| 669 g_loot = {} -- not saved, just fooling PLAYER_LOGOUT tests | 715 g_loot = {} -- not saved, just fooling PLAYER_LOGOUT tests |
