diff gui.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/gui.lua	Mon Jun 11 21:03:16 2012 +0000
+++ b/gui.lua	Tue Jun 12 03:46:00 2012 +0000
@@ -66,11 +66,13 @@
 
 local pprint, tabledump = addon.pprint, flib.tabledump
 local GetItemInfo, ITEM_QUALITY_COLORS = GetItemInfo, ITEM_QUALITY_COLORS
+local GetNumRaidMembers = GetNumRaidMembers
 
 -- En masse forward decls of symbols defined inside local blocks
 local _generate_text, _populate_text_specials
-local _tabtexts, _taborder -- filled out in gui block scope
+local eoi_dropdownfuncs, _tabtexts, _taborder -- filled out in gui block scope
 local _do_debugging_tooltip, _hide_debugging_tooltip, _build_debugging_tooltip
+local _new_rebroadcast_hyperlink
 
 --[[
 This is a table of callback functions, each responsible for drawing a tab
@@ -600,6 +602,26 @@
 	end
 end
 
+do
+	local rebroadcast_map  -- XXX weaken this somehow?
+
+	local function onclick (self, ident)
+		local data = assert(rebroadcast_map[ident])
+		eoi_dropdownfuncs["Rebroadcast this loot entry"](data.rowindex)
+		-- XXX delete the entry maybe?
+	end
+
+	function _new_rebroadcast_hyperlink (data)
+		rebroadcast_map = rebroadcast_map or flib.new()
+		local clicky, ident = addon.format_hypertext(
+			-- same color sequence as what DBM uses to announce pizza timers,
+			-- which looks reasonably pleasing
+			[[Broadcast this entry]], "|cff3588ff", onclick)
+		rebroadcast_map[ident] = data
+		return clicky
+	end
+end
+
 
 ------ Main GUI Window
 local _d   -- display when it's open, eoiST when it's not
@@ -746,7 +768,6 @@
 
 -- Tab 1:  Events Of Interest
 -- This actually takes up quite a bit of the file.
-local eoi_dropdownfuncs
 eoi_dropdownfuncs = dropdownfuncs{
 	df_INSERT = function(rowi,text)
 		local which = (text == 'loot') and "OUROL_EOI_INSERT_LOOT" or "OUROL_EOI_INSERT"
@@ -2720,7 +2741,7 @@
 		addon:_mark_boss_kill(data.rowindex)
 		data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex)
 		dialog.data = nil   -- free up memory
-		addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex)
+		addon:Print("Inserted %s %s at entry %d.", data.kind, data.name, data.rowindex)
 		return
 	end
 
@@ -2764,18 +2785,16 @@
 
 local function eoi_st_insert_OnAccept_loot (dialog, data)
 	if data.all_done then
-		--local real_rebroadcast, real_enabled = addon.rebroadcast, addon.enabled
-		--g_rebroadcast, g_enabled = false, true
 		data.display:Hide()
 		local loot_index = assert(addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes))
-		--g_rebroadcast, g_enabled = real_g_rebroadcast, real_g_enabled
 		local entry = tremove(g_loot,loot_index)
 		tinsert(g_loot,data.rowindex,entry)
-		--data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex)
 		addon:_fill_out_eoi_data(data.rowindex)
 		addon:BuildMainDisplay()
+		local clicky = _new_rebroadcast_hyperlink (data)
 		dialog.data = nil
-		addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex)
+		addon:Print ("Inserted %s %s at entry %d.  %s",
+			data.kind, data.name, data.rowindex, tostring(clicky))
 		return
 	end
 
@@ -2802,7 +2821,10 @@
 	if text then
 		data.name = text
 		dialog:Hide()  -- technically a "different" one about to be shown
+		StaticPopupDialogs["OUROL_EOI_INSERT"].autoCompleteParams =
+			AUTOCOMPLETE_LIST_TEMPLATES[GetNumRaidMembers() > 0 and "IN_GROUP" or "IN_GUILD"]
 		local getrecipient = StaticPopup_Show("OUROL_EOI_INSERT","recipient")
+		StaticPopupDialogs["OUROL_EOI_INSERT"].autoCompleteParams = nil
 		getrecipient.data = data
 		getrecipient.editBox:SetText("")
 		return true
@@ -2828,11 +2850,6 @@
 		editBoxWidth = 350,
 		maxLetters = 50,
 		noCancelOnReuse = true,
-		--[[ XXX still needed?
-		OnShow = function(dialog)
-			dialog.wideEditBox:SetText("")
-			dialog.wideEditBox:SetFocus()
-		end,]]
 	}
 	t.EditBoxOnEnterPressed = function(editbox)
 		if editbox:GetText() == "" then return end