Mercurial > wow > ouroloot
comparison core.lua @ 103:dc8a23a47b03
- Add 'chatprefix' function for building loot line jump links, and a
'PCFPrint' method which displays them.
- Make use of them for local and remote notifications, boss kills,
and manual insertions.
- Document the additional slash commands and args feature from previous
release. Oops. (Text mostly copied from webpage announcement.)
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Sun, 05 Aug 2012 07:26:06 +0000 |
| parents | fe04f5c4114a |
| children | 04198c8d0717 |
comparison
equal
deleted
inserted
replaced
| 102:fe04f5c4114a | 103:dc8a23a47b03 |
|---|---|
| 279 bossmod_registered = nil | 279 bossmod_registered = nil |
| 280 bossmods = {} | 280 bossmods = {} |
| 281 | 281 |
| 282 requesting = nil -- prompting for additional rebroadcasters | 282 requesting = nil -- prompting for additional rebroadcasters |
| 283 | 283 |
| 284 lootjumps = {} -- maps hypertext idents to EOI line numbers | |
| 285 | |
| 284 -- don't use NUM_ITEM_QUALITIES as the upper loop bound unless we expect | 286 -- don't use NUM_ITEM_QUALITIES as the upper loop bound unless we expect |
| 285 -- heirlooms to show up | 287 -- heirlooms to show up |
| 286 thresholds = {} | 288 thresholds = {} |
| 287 for i = 0,6 do | 289 for i = 0,6 do |
| 288 thresholds[i] = _G.ITEM_QUALITY_COLORS[i].hex .. _G["ITEM_QUALITY"..i.."_DESC"] .. "|r" | 290 thresholds[i] = _G.ITEM_QUALITY_COLORS[i].hex .. _G["ITEM_QUALITY"..i.."_DESC"] .. "|r" |
| 419 | 421 |
| 420 -- Hypertext support, inspired by DBM broadcast pizza timers | 422 -- Hypertext support, inspired by DBM broadcast pizza timers |
| 421 do | 423 do |
| 422 local hypertext_format_str = "|HOuroLoot:%d|h%s[%s]|r|h" | 424 local hypertext_format_str = "|HOuroLoot:%d|h%s[%s]|r|h" |
| 423 local func_map = {} --_G.setmetatable({}, {__mode = 'k'}) | 425 local func_map = {} --_G.setmetatable({}, {__mode = 'k'}) |
| 424 local text_map = {} --_G.setmetatable({}, {__mode = 'kv'}) | 426 local text_map = {} _G.setmetatable({}, {__mode = 'v'}) |
| 425 local base = _G.newproxy(true) | 427 local base = _G.newproxy(true) |
| 426 _G.getmetatable(base).__tostring = function(ud) return text_map[ud] end | 428 _G.getmetatable(base).__tostring = function(ud) return text_map[ud] end |
| 427 --@debug@ | 429 --@debug@ |
| 428 -- collecting these tokens is an interesting micro-optimization but not yet | 430 -- auto collecting these tokens is an interesting micro-optimization but not yet |
| 431 _G.getmetatable(base).__index = { | |
| 432 ['done'] = function (ud) | |
| 433 text_map[ud] = nil | |
| 434 func_map[ud] = nil | |
| 435 end, | |
| 436 } | |
| 429 _G.getmetatable(base).__gc = function(ud) | 437 _G.getmetatable(base).__gc = function(ud) |
| 430 print("Collecting hyperlink object <",tostring(ud),">") | 438 print("Collecting hyperlink object <",tostring(ud),">") |
| 431 end | 439 end |
| 432 --@end-debug@ | 440 --@end-debug@ |
| 433 | 441 |
| 858 -- frame-ness, which would slow down all printing and only rarely be useful. | 866 -- frame-ness, which would slow down all printing and only rarely be useful. |
| 859 -- | 867 -- |
| 860 -- There is no ITEM_QUALITY_LEGENDARY constant. Sigh. | 868 -- There is no ITEM_QUALITY_LEGENDARY constant. Sigh. |
| 861 do | 869 do |
| 862 local AC = LibStub("AceConsole-3.0") | 870 local AC = LibStub("AceConsole-3.0") |
| 863 local chat_prefix = self.format_hypertext ("Ouro Loot", --[[legendary]]5, | 871 function addon.chatprefix (code, arg) |
| 864 --[[empty -> nil -> main tab]]'') | 872 local f = '' -- empty -> BuildMainDisplay(empty) -> main tab |
| 865 local chat_prefix_s = tostring(chat_prefix) | 873 if code == "GoToLootLine" then |
| 874 f = code | |
| 875 --elseif ..... | |
| 876 end | |
| 877 local ret, num = self.format_hypertext ("Ouro Loot", --[[legendary]]5, f) | |
| 878 if code == "GoToLootLine" then | |
| 879 self.lootjumps[num] = arg | |
| 880 end | |
| 881 return ret, num | |
| 882 end | |
| 883 --local chat_prefix = self.format_hypertext ("Ouro Loot", --[[legendary]]5, '') | |
| 884 --local chat_prefix_s = tostring(chat_prefix) | |
| 885 local chat_prefix_s = tostring((addon.chatprefix())) | |
| 866 function addon:Print (str, ...) | 886 function addon:Print (str, ...) |
| 867 if type(str) == 'string' and str:find("%", nil, --[[plainmatch=]]true) then | 887 if type(str) == 'string' and str:find("%", nil, --[[plainmatch=]]true) then |
| 868 return AC:Print (chat_prefix_s, str:format(...)) | 888 return AC:Print (chat_prefix_s, str:format(...)) |
| 869 else | 889 else |
| 870 return AC:Print (chat_prefix_s, str, ...) | 890 return AC:Print (chat_prefix_s, str, ...) |
| 874 assert(type(frame)=='table' and frame.AddMessage) | 894 assert(type(frame)=='table' and frame.AddMessage) |
| 875 if type(str) == 'string' and str:find("%", nil, --[[plainmatch=]]true) then | 895 if type(str) == 'string' and str:find("%", nil, --[[plainmatch=]]true) then |
| 876 return AC:Print (frame, chat_prefix_s, str:format(...)) | 896 return AC:Print (frame, chat_prefix_s, str:format(...)) |
| 877 else | 897 else |
| 878 return AC:Print (frame, chat_prefix_s, str, ...) | 898 return AC:Print (frame, chat_prefix_s, str, ...) |
| 899 end | |
| 900 end | |
| 901 function addon:PCFPrint (frame, prefix, str, ...) | |
| 902 assert(type(frame)=='table' and frame.AddMessage) | |
| 903 if type(str) == 'string' and str:find("%", nil, --[[plainmatch=]]true) then | |
| 904 return AC:Print (frame, tostring(prefix), str:format(...)) | |
| 905 else | |
| 906 return AC:Print (frame, tostring(prefix), str, ...) | |
| 879 end | 907 end |
| 880 end | 908 end |
| 881 end | 909 end |
| 882 | 910 |
| 883 -- Copy these over once, now that other addons have mostly loaded. Any | 911 -- Copy these over once, now that other addons have mostly loaded. Any |
| 1964 .. to_text .. "|r" | 1992 .. to_text .. "|r" |
| 1965 end | 1993 end |
| 1966 | 1994 |
| 1967 addon.dprint ('loot', "notification:", source, index, | 1995 addon.dprint ('loot', "notification:", source, index, |
| 1968 e.itemlink, from_text, to_text) | 1996 e.itemlink, from_text, to_text) |
| 1969 addon:CFPrint (chatframe, remote_chatty, source, index, | 1997 local jumpprefix = addon.chatprefix ("GoToLootLine", index) |
| 1998 addon:PCFPrint (chatframe, jumpprefix, remote_chatty, source, index, | |
| 1970 e.itemlink, from_text, to_text) | 1999 e.itemlink, from_text, to_text) |
| 1971 end | 2000 end |
| 1972 | 2001 |
| 1973 function _notify_about_change (sender, index, olddisp, from_whom, from_class) | 2002 function _notify_about_change (sender, index, olddisp, from_whom, from_class) |
| 1974 _notify (change_chatframe, sender, index, olddisp, from_whom, from_class) | 2003 _notify (change_chatframe, sender, index, olddisp, from_whom, from_class) |
| 2204 addon.dprint('loot', "added boss entry", bossi) | 2233 addon.dprint('loot', "added boss entry", bossi) |
| 2205 if boss.reason == 'kill' then | 2234 if boss.reason == 'kill' then |
| 2206 addon:RegisterEvent ("PLAYER_REGEN_DISABLED") | 2235 addon:RegisterEvent ("PLAYER_REGEN_DISABLED") |
| 2207 addon:_mark_boss_kill (bossi) | 2236 addon:_mark_boss_kill (bossi) |
| 2208 if opts.chatty_on_kill then | 2237 if opts.chatty_on_kill then |
| 2209 addon:Print("Registered kill for '%s' in %s!", boss.bossname, boss.instance) | 2238 local jumpprefix = addon.chatprefix ("GoToLootLine", bossi) |
| 2239 addon:PCFPrint(_G.DEFAULT_CHAT_FRAME, jumpprefix, | |
| 2240 "Registered kill for '%s' in %s!", boss.bossname, boss.instance) | |
| 2210 end | 2241 end |
| 2211 end | 2242 end |
| 2212 wipe(candidates) | 2243 wipe(candidates) |
| 2213 end | 2244 end |
| 2214 -- Ten seconds is a long time, but occasionally DBM takes for-EVAH to | 2245 -- Ten seconds is a long time, but occasionally DBM takes for-EVAH to |
