Mercurial > wow > ouroloot
comparison core.lua @ 78:f8118aa5fbb8
Manually inserting loot entries now (1) uses autocomplete dropdowns for the recipient name (raid members if in a raid, online guild members otherwise), and (2) adds a rebroadcasting hyperlink to the text response. Clicking the link rebroadcasts just like the context menu.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Tue, 12 Jun 2012 03:46:00 +0000 |
parents | a07c9dd79f3a |
children | 0235a1695b83 |
comparison
equal
deleted
inserted
replaced
77:a07c9dd79f3a | 78:f8118aa5fbb8 |
---|---|
380 | 380 |
381 -- TEXT will automatically be surrounded by brackets | 381 -- TEXT will automatically be surrounded by brackets |
382 -- COLOR can be ITEM_QUALITY_* or a formatting string ("|cff...") | 382 -- COLOR can be ITEM_QUALITY_* or a formatting string ("|cff...") |
383 -- FUNC can be "MethodName", "tab_title", or a function | 383 -- FUNC can be "MethodName", "tab_title", or a function |
384 -- | 384 -- |
385 -- Returns an obaque token. Calling tostring() on the token will yield a | 385 -- Returns an opaque token and a matching number. Calling tostring() on |
386 -- formatted clickable string that can be displayed in chat. This is | 386 -- the token will yield a formatted clickable string that can be displayed |
387 -- largely an excuse to fool around with Lua data constructs. | 387 -- in chat. The MethodName and raw function callbacks will both be |
388 -- passed the addon table and the same matching number. | |
389 -- | |
390 -- This is largely an excuse to fool around with Lua data constructs. | |
388 function addon.format_hypertext (text, color, func) | 391 function addon.format_hypertext (text, color, func) |
389 local ret = _G.newproxy(base) | 392 local ret = _G.newproxy(base) |
390 local num = #text_map + 1 | 393 local num = #text_map + 1 |
391 text_map[ret] = hypertext_format_str:format (num, | 394 text_map[ret] = hypertext_format_str:format (num, |
392 type(color)=='number' and ITEM_QUALITY_COLORS[color].hex or color, | 395 type(color)=='number' and ITEM_QUALITY_COLORS[color].hex or color, |
393 text) | 396 text) |
394 text_map[num] = ret | 397 text_map[num] = ret |
395 func_map[ret] = func | 398 func_map[ret] = func |
396 return ret | 399 return ret, num |
397 end | 400 end |
398 | 401 |
399 --[[ | 402 --[[ |
400 link: OuroLoot:n | 403 link: OuroLoot:n |
401 fullstring: |HOuroLoot:n|h|cff.....[foo]|r|h | 404 fullstring: |HOuroLoot:n|h|cff.....[foo]|r|h |
406 ]] | 409 ]] |
407 local strsplit = _G.strsplit | 410 local strsplit = _G.strsplit |
408 DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, fullstring, mousebutton) | 411 DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, fullstring, mousebutton) |
409 local ltype, arg = strsplit(":",link) | 412 local ltype, arg = strsplit(":",link) |
410 if ltype ~= "OuroLoot" then return end | 413 if ltype ~= "OuroLoot" then return end |
411 local f = func_map[text_map[tonumber(arg)]] | 414 arg = tonumber(arg) |
415 local f = func_map[text_map[arg]] | |
412 if type(f) == 'function' then | 416 if type(f) == 'function' then |
413 f() | 417 f (addon, arg) |
414 elseif type(f) == 'string' then | 418 elseif type(f) == 'string' then |
415 if type(addon[f]) == 'function' then | 419 if type(addon[f]) == 'function' then |
416 addon[f](addon) -- method name | 420 addon[f](addon,arg) -- method name |
417 else | 421 else |
418 addon:BuildMainDisplay(f) -- tab title fragment | 422 addon:BuildMainDisplay(f) -- tab title fragment |
419 end | 423 end |
420 end | 424 end |
421 end) | 425 end) |
1664 if #g_loot == 0 then | 1668 if #g_loot == 0 then |
1665 -- only generated text and raider join/leave data, not worth verbage | 1669 -- only generated text and raider join/leave data, not worth verbage |
1666 self.dprint('flow', ">:Activate restored generated texts, un-popping") | 1670 self.dprint('flow', ">:Activate restored generated texts, un-popping") |
1667 return | 1671 return |
1668 end | 1672 end |
1669 self:Print("Ouro Raid Loot restored previous data, but not in a raid", | 1673 self:Print("Restored previous data, but not in a raid", |
1670 "and 5-player mode not active. |cffff0505NOT tracking loot|r;", | 1674 "and 5-player mode not active. |cffff0505NOT tracking loot|r;", |
1671 "use 'enable' to activate loot tracking, or 'clear' to erase", | 1675 "use 'enable' to activate loot tracking, or 'clear' to erase", |
1672 "previous data, or 'help' to read about saved-texts commands.") | 1676 "previous data, or 'help' to read about saved-texts commands.") |
1673 return | 1677 return |
1674 end | 1678 end |
3169 addon:on_boss_broadcast (reason, bossname, instancetag, maxsize) | 3173 addon:on_boss_broadcast (reason, bossname, instancetag, maxsize) |
3170 end | 3174 end |
3171 OCR_funcs['17boss'] = OCR_funcs['16boss'] | 3175 OCR_funcs['17boss'] = OCR_funcs['16boss'] |
3172 | 3176 |
3173 local bcast_on = addon.format_hypertext ([[the red pill]], '|cffff4040', | 3177 local bcast_on = addon.format_hypertext ([[the red pill]], '|cffff4040', |
3174 function() | 3178 function (self) |
3175 if not addon.rebroadcast then | 3179 if not self.rebroadcast then |
3176 addon:Activate(nil,true) | 3180 self:Activate(nil,true) |
3177 end | 3181 end |
3178 addon:broadcast('bcast_responder') | 3182 self:broadcast('bcast_responder') |
3179 end) | 3183 end) |
3180 local waferthin = addon.format_hypertext ([[the blue pill]], '|cff0070dd', | 3184 local waferthin = addon.format_hypertext ([[the blue pill]], '|cff0070dd', |
3181 function() | 3185 function (self) |
3182 g_wafer_thin = true -- mint? it's wafer thin! | 3186 g_wafer_thin = true -- mint? it's wafer thin! |
3183 addon:broadcast('bcast_denied') -- fuck off, I'm full | 3187 self:broadcast('bcast_denied') -- fuck off, I'm full |
3184 end) | 3188 end) |
3185 OCR_funcs.bcast_req = function (sender) | 3189 OCR_funcs.bcast_req = function (sender) |
3186 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast)) | 3190 if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast)) |
3187 then | 3191 then |
3188 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.", | 3192 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.", |