Mercurial > wow > ouroloot
comparison core.lua @ 90:92e0db376858
Some initial prep for MoP API transition. (Some of this can be removed post-MoP-release, but fewer changes will need to be made the day of.)
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Sun, 01 Jul 2012 17:16:42 +0000 |
parents | 939569ded66f |
children | 01cfbfa96dd6 |
comparison
equal
deleted
inserted
replaced
89:939569ded66f | 90:92e0db376858 |
---|---|
108 OuroLootSV_hist = nil | 108 OuroLootSV_hist = nil |
109 OuroLootSV_log = {} | 109 OuroLootSV_log = {} |
110 | 110 |
111 | 111 |
112 ------ Constants | 112 ------ Constants |
113 local RAID_ROSTER_UPDATE_EVENT = | |
114 (select(4,GetBuildInfo()) >= 50000) and 'GROUP_ROSTER_UPDATE' or 'RAID_ROSTER_UPDATE' | |
113 local option_defaults = { | 115 local option_defaults = { |
114 ['datarev'] = 20, -- cheating, this isn't actually an option | 116 ['datarev'] = 20, -- cheating, this isn't actually an option |
115 ['popup_on_join'] = true, | 117 ['popup_on_join'] = true, |
116 ['register_slashloot'] = true, | 118 ['register_slashloot'] = true, |
117 ['scroll_to_bottom'] = true, | 119 ['scroll_to_bottom'] = true, |
375 local tostring = _G.tostring | 377 local tostring = _G.tostring |
376 local tonumber = _G.tonumber | 378 local tonumber = _G.tonumber |
377 local wipe = _G.table.wipe | 379 local wipe = _G.table.wipe |
378 | 380 |
379 local pprint, tabledump = addon.pprint, flib.tabledump | 381 local pprint, tabledump = addon.pprint, flib.tabledump |
380 local CopyTable, GetNumRaidMembers = _G.CopyTable, _G.GetNumRaidMembers | 382 local CopyTable = _G.CopyTable |
383 local GetNumRaidMembers = _G.GetNumGroupMembers or _G.GetNumRaidMembers | |
381 -- En masse forward decls of symbols defined inside local blocks | 384 -- En masse forward decls of symbols defined inside local blocks |
382 local _register_bossmod, makedate, create_new_cache, _init, _log | 385 local _register_bossmod, makedate, create_new_cache, _init, _log |
383 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision | 386 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision |
384 local _notify_about_change, _notify_about_remote | 387 local _notify_about_change, _notify_about_remote |
385 | 388 |
881 self.OnInitialize = nil -- free up ALL the things! | 884 self.OnInitialize = nil -- free up ALL the things! |
882 end | 885 end |
883 | 886 |
884 function addon:OnEnable() | 887 function addon:OnEnable() |
885 self:RegisterEvent("PLAYER_LOGOUT") | 888 self:RegisterEvent("PLAYER_LOGOUT") |
886 self:RegisterEvent("RAID_ROSTER_UPDATE") | 889 self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") |
887 | 890 |
888 -- Cribbed from Talented. I like the way jerry thinks: the first string | 891 -- Cribbed from Talented. I like the way jerry thinks: the first string |
889 -- argument can be a format spec for the remainder of the arguments. | 892 -- argument can be a format spec for the remainder of the arguments. |
890 -- AceConsole:Printf isn't used because we can't specify a prefix without | 893 -- AceConsole:Printf isn't used because we can't specify a prefix without |
891 -- jumping through ridonkulous hoops. The part about overriding :Print | 894 -- jumping through ridonkulous hoops. The part about overriding :Print |
1086 _G.OuroLootSV_hist = nil | 1089 _G.OuroLootSV_hist = nil |
1087 _G.OuroLootSV_log = nil | 1090 _G.OuroLootSV_log = nil |
1088 _G.ReloadUI() | 1091 _G.ReloadUI() |
1089 end | 1092 end |
1090 function addon:PLAYER_LOGOUT() | 1093 function addon:PLAYER_LOGOUT() |
1091 self:UnregisterEvent("RAID_ROSTER_UPDATE") | 1094 self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) |
1092 self:UnregisterEvent("PLAYER_ENTERING_WORLD") | 1095 self:UnregisterEvent("PLAYER_ENTERING_WORLD") |
1093 | 1096 |
1094 local worth_saving = #g_loot > 0 or _G.next(g_loot.raiders) | 1097 local worth_saving = #g_loot > 0 or _G.next(g_loot.raiders) |
1095 if not worth_saving then for text in self:registered_textgen_iter() do | 1098 if not worth_saving then for text in self:registered_textgen_iter() do |
1096 worth_saving = worth_saving or g_loot.printed[text] > 0 | 1099 worth_saving = worth_saving or g_loot.printed[text] > 0 |
1235 if event == "Activate" then | 1238 if event == "Activate" then |
1236 -- dispatched manually from Activate | 1239 -- dispatched manually from Activate |
1237 self:RegisterEvent("CHAT_MSG_LOOT") | 1240 self:RegisterEvent("CHAT_MSG_LOOT") |
1238 _register_bossmod(self) | 1241 _register_bossmod(self) |
1239 docheck = true | 1242 docheck = true |
1240 elseif event == "RAID_ROSTER_UPDATE" then | 1243 elseif event == RAID_ROSTER_UPDATE_EVENT then |
1241 -- hot code path, be careful | 1244 -- hot code path, be careful |
1242 | 1245 |
1243 -- event registration from onload, joined a raid, maybe show popup | 1246 -- event registration from onload, joined a raid, maybe show popup |
1244 self.dprint('flow', "RRU check:", self.popped, opts.popup_on_join) | 1247 self.dprint('flow', "RRU check:", self.popped, opts.popup_on_join) |
1245 if (not self.popped) and opts.popup_on_join then | 1248 if (not self.popped) and opts.popup_on_join then |
1704 | 1707 |
1705 ------ On/off | 1708 ------ On/off |
1706 -- Both of these need to be (effectively) idempotent. | 1709 -- Both of these need to be (effectively) idempotent. |
1707 function addon:Activate (opt_threshold, opt_bcast_only) | 1710 function addon:Activate (opt_threshold, opt_bcast_only) |
1708 self.dprint('flow', ":Activate is running") | 1711 self.dprint('flow', ":Activate is running") |
1709 self:RegisterEvent("RAID_ROSTER_UPDATE") | 1712 self:RegisterEvent(RAID_ROSTER_UPDATE_EVENT,"RAID_ROSTER_UPDATE") |
1710 self:RegisterEvent("PLAYER_ENTERING_WORLD", | 1713 self:RegisterEvent("PLAYER_ENTERING_WORLD", |
1711 function() self:ScheduleTimer("RAID_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) | 1714 function() self:ScheduleTimer("RAID_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end) |
1712 self.popped = true | 1715 self.popped = true |
1713 if GetNumRaidMembers() > 0 then | 1716 if GetNumRaidMembers() > 0 then |
1714 self.dprint('flow', ">:Activate calling RRU") | 1717 self.dprint('flow', ">:Activate calling RRU") |
1746 -- Note: running '/loot off' will also avoid the popup reminder when | 1749 -- Note: running '/loot off' will also avoid the popup reminder when |
1747 -- joining a raid, but will not change the saved option setting. | 1750 -- joining a raid, but will not change the saved option setting. |
1748 function addon:Deactivate() | 1751 function addon:Deactivate() |
1749 self.enabled = false | 1752 self.enabled = false |
1750 self.rebroadcast = false | 1753 self.rebroadcast = false |
1751 self:UnregisterEvent("RAID_ROSTER_UPDATE") | 1754 self:UnregisterEvent(RAID_ROSTER_UPDATE_EVENT) |
1752 self:UnregisterEvent("PLAYER_ENTERING_WORLD") | 1755 self:UnregisterEvent("PLAYER_ENTERING_WORLD") |
1753 self:UnregisterEvent("CHAT_MSG_LOOT") | 1756 self:UnregisterEvent("CHAT_MSG_LOOT") |
1754 self:Print("Deactivated.") | 1757 self:Print("Deactivated.") |
1755 end | 1758 end |
1756 | 1759 |