comparison core.lua @ 95:3546c7b55986

Move generation of the Help tab to the same file as the help text. Allow registration of arbitrary tab controls, not just text generation. Move some shared data out of the addon table into a 'gui' state table in preparation for more of the same. Clean some cruft out of the default itemfilter list.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 26 Jul 2012 03:34:56 +0000
parents db1d5d09e5f5
children 780b7e0eeeeb
comparison
equal deleted inserted replaced
94:db1d5d09e5f5 95:3546c7b55986
137 ['display_bcast_from'] = true, 137 ['display_bcast_from'] = true,
138 ['precache_history_uniques'] = false, 138 ['precache_history_uniques'] = false,
139 ['chatty_on_remote_changes'] = false, 139 ['chatty_on_remote_changes'] = false,
140 ['chatty_on_remote_changes_frame'] = 1, 140 ['chatty_on_remote_changes_frame'] = 1,
141 } 141 }
142 local virgin = "First time loaded? Hi! Use the /ouroloot or /loot command" 142 local virgin = "First time loaded? Hi! Use the /ouroloot command"
143 .." to show the main display. You should probably browse the instructions" 143 .." to show the main display. You should probably browse the instructions"
144 .." if you've never used this before; %s to display the help window. This" 144 .." if you've never used this before; %s to display the help window. This"
145 .." welcome message will not intrude again." 145 .." welcome message will not intrude again."
146 local newer_warning = "A newer version has been released. You can %s to display" 146 local newer_warning = "A newer version has been released. You can %s to display"
147 .." a download URL for copy-and-pasting. You can %s to ping other raiders" 147 .." a download URL for copy-and-pasting. You can %s to ping other raiders"
763 end 763 end
764 764
765 -- get item filter table if needed 765 -- get item filter table if needed
766 if opts.itemfilter == nil then 766 if opts.itemfilter == nil then
767 opts.itemfilter = self.default_itemfilter 767 opts.itemfilter = self.default_itemfilter
768 else
769 -- remove old stuff that doesn't "drop" anymore
770 -- find some way of only doing this once
771 opts.itemfilter[29434] = nil -- Badge of Justice
772 opts.itemfilter[40752] = nil -- Emblem of Heroism
773 opts.itemfilter[40753] = nil -- Emblem of Valor
774 opts.itemfilter[45624] = nil -- Emblem of Conquest
775 opts.itemfilter[43228] = nil -- Stone Keeper's Shard
776 opts.itemfilter[47241] = nil -- Emblem of Triumph
777 opts.itemfilter[49426] = nil -- Emblem of Frost
768 end 778 end
769 self.default_itemfilter = nil 779 self.default_itemfilter = nil
770 if opts.itemvault == nil then 780 if opts.itemvault == nil then
771 opts.itemvault = self.default_itemvault 781 opts.itemvault = self.default_itemvault
772 end 782 end
889 stored_datarev = stored_datarev + 1 899 stored_datarev = stored_datarev + 1
890 end 900 end
891 if dirty then self:Print("Saved data has been massaged into shape.") end 901 if dirty then self:Print("Saved data has been massaged into shape.") end
892 end 902 end
893 903
904 self:FINISH_SPECIAL_TABS()
894 _init(self) 905 _init(self)
895 self.dprint('flow', "version strings:", version_large, self.revision, self.status_text) 906 self.dprint('flow', "version strings:", version_large, self.revision, self.status_text)
907 self.gui_state_pointer = nil
896 self.load_assert = nil 908 self.load_assert = nil
897 self.OnInitialize = nil -- free up ALL the things! 909 self.OnInitialize = nil -- free up ALL the things!
898 end 910 end
899 911
900 function addon:OnEnable() 912 function addon:OnEnable()
1031 end 1043 end
1032 --function addon:OnDisable() end 1044 --function addon:OnDisable() end
1033 1045
1034 do 1046 do
1035 local prototype = {} 1047 local prototype = {}
1048 local registry
1049
1050 -- By default, no plugins. First one in sets up code for any after.
1051 addon.get_plugin = flib.nullfunc
1052
1053 -- Fires before the plugin's own OnEnable (inherited or otherwise).
1054 function addon:OnModuleCreated (plugin)
1055 if not registry then
1056 registry = {}
1057 addon.get_plugin = function(a,t) return registry[t] end
1058 prototype.register_text_generator = function(p,t,...)
1059 registry[t] = p
1060 return addon:register_text_generator(t,...)
1061 end
1062 prototype.register_tab_control = function(p,t,...)
1063 registry[t] = p
1064 return addon:register_tab_control(t,...)
1065 end
1066 end
1067 end
1068
1036 local function module_OnEnable (plugin) 1069 local function module_OnEnable (plugin)
1037 if plugin.option_defaults then 1070 if plugin.option_defaults then
1038 local SVname = 'OuroLoot'..plugin:GetName()..'_opts' 1071 local SVname = 'OuroLoot'..plugin:GetName()..'_opts'
1039 if not _G[SVname] then 1072 if not _G[SVname] then
1040 _G[SVname] = {} 1073 _G[SVname] = {}
1050 end 1083 end
1051 plugin.option_defaults = nil 1084 plugin.option_defaults = nil
1052 end 1085 end
1053 end 1086 end
1054 1087
1055 -- By default, no plugins. First plugin to use the special registration
1056 -- sets up code for any subsequent plugins.
1057 addon.is_plugin = flib.nullfunc
1058 local function module_rtg (plugin, text_type, ...)
1059 local registry = { [text_type]=plugin }
1060 addon.is_plugin = function(a,t) return registry[t] end
1061 prototype.register_text_generator = function(p,t,...)
1062 registry[t] = p
1063 return addon:register_text_generator(t,...)
1064 end
1065 return addon:register_text_generator(text_type,...)
1066 end
1067
1068 prototype.OnEnable = module_OnEnable 1088 prototype.OnEnable = module_OnEnable
1069 prototype.default_OnEnable = module_OnEnable 1089 prototype.default_OnEnable = module_OnEnable
1070 prototype.register_text_generator = module_rtg
1071 1090
1072 addon:SetDefaultModuleLibraries("AceConsole-3.0") 1091 addon:SetDefaultModuleLibraries("AceConsole-3.0")
1073 addon:SetDefaultModulePrototype(prototype) 1092 addon:SetDefaultModulePrototype(prototype)
1074 -- Fires before the plugin's own OnEnable (inherited or otherwise).
1075 --function addon:OnModuleCreated (plugin)
1076 -- print("created plugin", plugin:GetName())
1077 --end
1078 1093
1079 local err = [[Module '%s' cannot register itself because it failed a required condition: '%s']] 1094 local err = [[Module '%s' cannot register itself because it failed a required condition: '%s']]
1080 function addon:ConstrainedNewModule (modname, minrev, mincomm, mindata) 1095 function addon:ConstrainedNewModule (modname, minrev, mincomm, mindata)
1081 if not addon.author_debug then 1096 if not addon.author_debug then
1082 if minrev and tonumber(minrev) > (tonumber(self.revision) or math.huge) then 1097 if minrev and tonumber(minrev) > (tonumber(self.revision) or math.huge) then
1683 elseif cmd == "ping" then 1698 elseif cmd == "ping" then
1684 self:DoPing() 1699 self:DoPing()
1685 1700
1686 elseif cmd == "fix" then 1701 elseif cmd == "fix" then
1687 if arg == "?" then 1702 if arg == "?" then
1688 self:Print[['/loot fix cache' updates loot that wasn't in the cache]] 1703 self:Print[['/ouroloot fix cache' updates loot that wasn't in the cache]]
1689 self:Print[['/loot fix history' repairs inconsistent data on the History tab]] 1704 self:Print[['/ouroloot fix history' repairs inconsistent data on the History tab]]
1690 self:Print[['/loot fix' changes no stored data, only allows the window to be displayed again (this is built into all fixes above)]] 1705 self:Print[['/ouroloot fix' changes no stored data, only allows the window to be displayed again (this is built into all fixes above)]]
1691 return 1706 return
1692 elseif arg == "cache" then 1707 elseif arg == "cache" then
1693 self:do_item_cache_fixup() 1708 self:do_item_cache_fixup()
1694 elseif arg == "history" then 1709 elseif arg == "history" then
1695 self:repair_history_integrity() 1710 self:repair_history_integrity()
1764 self.enabled and "tracking" or "only broadcasting", 1779 self.enabled and "tracking" or "only broadcasting",
1765 self.thresholds[self.threshold]) 1780 self.thresholds[self.threshold])
1766 self:broadcast('revcheck',version_large) 1781 self:broadcast('revcheck',version_large)
1767 end 1782 end
1768 1783
1769 -- Note: running '/loot off' will also avoid the popup reminder when 1784 -- Note: running '/ouroloot off' will also avoid the popup reminder when
1770 -- joining a raid, but will not change the saved option setting. 1785 -- joining a raid, but will not change the saved option setting.
1771 function addon:Deactivate() 1786 function addon:Deactivate()
1772 self.enabled = false 1787 self.enabled = false
1773 self.rebroadcast = false 1788 self.rebroadcast = false
1774 self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) 1789 self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT)
3512 self:broadcast('bcast_denied') -- fuck off, I'm full 3527 self:broadcast('bcast_denied') -- fuck off, I'm full
3513 end) 3528 end)
3514 OCR_funcs.bcast_req = function (sender) 3529 OCR_funcs.bcast_req = function (sender)
3515 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast)) 3530 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast))
3516 then 3531 then
3517 addon:Print("%s has requested additional broadcasters! Choose %s to enable rebroadcasting, or %s to remain off and also ignore rebroadcast requests for as long as you're logged in.", 3532 addon:Print("%s has requested additional broadcasters! Click %s to enable rebroadcasting, or %s to remain off and also ignore rebroadcast requests for as long as you're logged in.",
3518 sender, 3533 sender,
3519 tostring(bcast_on), 3534 tostring(bcast_on),
3520 tostring(waferthin)) 3535 tostring(waferthin))
3521 end 3536 end
3522 addon.popped = true 3537 addon.popped = true