Mercurial > wow > ouroloot
diff 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 |
line wrap: on
line diff
--- a/core.lua Sat Aug 04 22:03:05 2012 +0000 +++ b/core.lua Sun Aug 05 07:26:06 2012 +0000 @@ -281,6 +281,8 @@ requesting = nil -- prompting for additional rebroadcasters + lootjumps = {} -- maps hypertext idents to EOI line numbers + -- don't use NUM_ITEM_QUALITIES as the upper loop bound unless we expect -- heirlooms to show up thresholds = {} @@ -421,11 +423,17 @@ do local hypertext_format_str = "|HOuroLoot:%d|h%s[%s]|r|h" local func_map = {} --_G.setmetatable({}, {__mode = 'k'}) - local text_map = {} --_G.setmetatable({}, {__mode = 'kv'}) + local text_map = {} _G.setmetatable({}, {__mode = 'v'}) local base = _G.newproxy(true) _G.getmetatable(base).__tostring = function(ud) return text_map[ud] end --@debug@ - -- collecting these tokens is an interesting micro-optimization but not yet + -- auto collecting these tokens is an interesting micro-optimization but not yet + _G.getmetatable(base).__index = { + ['done'] = function (ud) + text_map[ud] = nil + func_map[ud] = nil + end, + } _G.getmetatable(base).__gc = function(ud) print("Collecting hyperlink object <",tostring(ud),">") end @@ -860,9 +868,21 @@ -- There is no ITEM_QUALITY_LEGENDARY constant. Sigh. do local AC = LibStub("AceConsole-3.0") - local chat_prefix = self.format_hypertext ("Ouro Loot", --[[legendary]]5, - --[[empty -> nil -> main tab]]'') - local chat_prefix_s = tostring(chat_prefix) + function addon.chatprefix (code, arg) + local f = '' -- empty -> BuildMainDisplay(empty) -> main tab + if code == "GoToLootLine" then + f = code + --elseif ..... + end + local ret, num = self.format_hypertext ("Ouro Loot", --[[legendary]]5, f) + if code == "GoToLootLine" then + self.lootjumps[num] = arg + end + return ret, num + end + --local chat_prefix = self.format_hypertext ("Ouro Loot", --[[legendary]]5, '') + --local chat_prefix_s = tostring(chat_prefix) + local chat_prefix_s = tostring((addon.chatprefix())) function addon:Print (str, ...) if type(str) == 'string' and str:find("%", nil, --[[plainmatch=]]true) then return AC:Print (chat_prefix_s, str:format(...)) @@ -878,6 +898,14 @@ return AC:Print (frame, chat_prefix_s, str, ...) end end + function addon:PCFPrint (frame, prefix, str, ...) + assert(type(frame)=='table' and frame.AddMessage) + if type(str) == 'string' and str:find("%", nil, --[[plainmatch=]]true) then + return AC:Print (frame, tostring(prefix), str:format(...)) + else + return AC:Print (frame, tostring(prefix), str, ...) + end + end end -- Copy these over once, now that other addons have mostly loaded. Any @@ -1966,7 +1994,8 @@ addon.dprint ('loot', "notification:", source, index, e.itemlink, from_text, to_text) - addon:CFPrint (chatframe, remote_chatty, source, index, + local jumpprefix = addon.chatprefix ("GoToLootLine", index) + addon:PCFPrint (chatframe, jumpprefix, remote_chatty, source, index, e.itemlink, from_text, to_text) end @@ -2206,7 +2235,9 @@ addon:RegisterEvent ("PLAYER_REGEN_DISABLED") addon:_mark_boss_kill (bossi) if opts.chatty_on_kill then - addon:Print("Registered kill for '%s' in %s!", boss.bossname, boss.instance) + local jumpprefix = addon.chatprefix ("GoToLootLine", bossi) + addon:PCFPrint(_G.DEFAULT_CHAT_FRAME, jumpprefix, + "Registered kill for '%s' in %s!", boss.bossname, boss.instance) end end wipe(candidates)