diff 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
line wrap: on
line diff
--- a/core.lua	Mon Jun 11 21:03:16 2012 +0000
+++ b/core.lua	Tue Jun 12 03:46:00 2012 +0000
@@ -382,9 +382,12 @@
 	-- COLOR can be ITEM_QUALITY_* or a formatting string ("|cff...")
 	-- FUNC can be "MethodName", "tab_title", or a function
 	--
-	-- Returns an obaque token.  Calling tostring() on the token will yield a
-	-- formatted clickable string that can be displayed in chat.  This is
-	-- largely an excuse to fool around with Lua data constructs.
+	-- Returns an opaque token and a matching number.  Calling tostring() on
+	-- the token will yield a formatted clickable string that can be displayed
+	-- in chat.  The MethodName and raw function callbacks will both be
+	-- passed the addon table and the same matching number.
+	--
+	-- This is largely an excuse to fool around with Lua data constructs.
 	function addon.format_hypertext (text, color, func)
 		local ret = _G.newproxy(base)
 		local num = #text_map + 1
@@ -393,7 +396,7 @@
 				text)
 		text_map[num] = ret
 		func_map[ret] = func
-		return ret
+		return ret, num
 	end
 
 	--[[
@@ -408,12 +411,13 @@
 	DEFAULT_CHAT_FRAME:HookScript("OnHyperlinkClick", function(self, link, fullstring, mousebutton)
 		local ltype, arg = strsplit(":",link)
 		if ltype ~= "OuroLoot" then return end
-		local f = func_map[text_map[tonumber(arg)]]
+		arg = tonumber(arg)
+		local f = func_map[text_map[arg]]
 		if type(f) == 'function' then
-			f()
+			f (addon, arg)
 		elseif type(f) == 'string' then
 			if type(addon[f]) == 'function' then
-				addon[f](addon)             -- method name
+				addon[f](addon,arg)         -- method name
 			else
 				addon:BuildMainDisplay(f)   -- tab title fragment
 			end
@@ -1666,7 +1670,7 @@
 			self.dprint('flow', ">:Activate restored generated texts, un-popping")
 			return
 		end
-		self:Print("Ouro Raid Loot restored previous data, but not in a raid",
+		self:Print("Restored previous data, but not in a raid",
 				"and 5-player mode not active.  |cffff0505NOT tracking loot|r;",
 				"use 'enable' to activate loot tracking, or 'clear' to erase",
 				"previous data, or 'help' to read about saved-texts commands.")
@@ -3171,16 +3175,16 @@
 	OCR_funcs['17boss'] = OCR_funcs['16boss']
 
 	local bcast_on = addon.format_hypertext ([[the red pill]], '|cffff4040',
-		function()
-			if not addon.rebroadcast then
-				addon:Activate(nil,true)
+		function (self)
+			if not self.rebroadcast then
+				self:Activate(nil,true)
 			end
-			addon:broadcast('bcast_responder')
+			self:broadcast('bcast_responder')
 		end)
 	local waferthin = addon.format_hypertext ([[the blue pill]], '|cff0070dd',
-		function()
+		function (self)
 			g_wafer_thin = true               -- mint? it's wafer thin!
-			addon:broadcast('bcast_denied')   -- fuck off, I'm full
+			self:broadcast('bcast_denied')   -- fuck off, I'm full
 		end)
 	OCR_funcs.bcast_req = function (sender)
 		if addon.debug.comm or ((not g_wafer_thin) and (not addon.rebroadcast))