diff gui.lua @ 128:dc39ce56a62d

- Adding new loot dispositions requires plugin module. - 'NewLootEntry' and 'NewEOIEntry' events also take a row index. (Hmmm) - Loot disposition options broken out into a submenu, and use the same color their notes text do. Toggle a checkbox for the current value.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Wed, 22 Aug 2012 23:37:24 -0400
parents 9232cacc9136
children 2731702567c4
line wrap: on
line diff
--- a/gui.lua	Sun Aug 19 22:08:17 2012 -0400
+++ b/gui.lua	Wed Aug 22 23:37:24 2012 -0400
@@ -449,9 +449,10 @@
 			e.cols[3].value = ""
 
 		end
+		self.loot_clean = i
 		break
 	end end
-	self.loot_clean = #g_loot
+	--self.loot_clean = #g_loot
 end
 
 do
@@ -1029,12 +1030,21 @@
 		E("Insert new boss kill event", 'df_INSERT', 'boss', "Inserts new event above this one, prompting you for information."),
 		E(CLOSE),
 	}
+	gui.dropdown.eoi_loot_mark = {}
 	gui.dropdown.eoi_loot = {
 		{
 			-- this is the dropdown title, text filled in on the fly
 			notClickable = true,
 			notCheckable = true,
 		},
+		{
+			text = "Mark as...",
+			hasArrow = true,
+			menuList = gui.dropdown.eoi_loot_mark,
+			tooltipOnButton = true,
+			tooltipWhileDisabled = true,
+			notCheckable = true,
+		},
 		E("--"),
 		E("Rebroadcast this loot entry", nil, nil, "Sends this loot event, including special notes, as if it just happened."),
 		E("Delete this loot event", 'df_DELETE', nil, "Permanent, no going back!\n\nHold down the Shift key to also delete the corresponding entry from player's History."),
@@ -1058,6 +1068,7 @@
 			--menuList = filled in in the fly,
 			tooltipOnButton = true,
 			tooltipWhileDisabled = true,
+			notCheckable = true,
 		},
 		E("Show only this player"),
 		E(CLOSE),
@@ -2329,36 +2340,57 @@
 
 -- We need to be able to reference the dropdownmenu locals, and I didn't want to
 -- bubble them up any higher.
-function gui.add_dropdown_entry (menutag, name, func_tbl, func_or_othername, arg, tooltiptext)
-	local emtbl = assert(gui.dropdown[menutag])
-
-	if type(func_tbl) == 'table' then
-		-- use it directly
-	elseif func_tbl == nil then
-		-- determine it from the menu tag
-		func_tbl = (menutag:sub(1,3) == 'eoi' and eoi_dropdownfuncs)
-			or (menutag:sub(1,4) == 'hist' and hist_dropdownfuncs)
-			or error("Cannot figure out function table from menu tag name")
+do
+	-- If the UIDropDownMenu_SetSelected* functions could be used with EasyMenu
+	-- in a sane fashion, we could dispense with the 'checked' field.
+	local function disposition_is_checked (buttonframe)
+		-- arg2 == disp code, GetID == index into dropdown array
+		local i = _d and _d.GetUserData and _d:GetUserData("DD index")
+		if i then
+			return g_loot[i].disposition == buttonframe.arg2
+		end
 	end
 
-	if type(func_or_othername) == 'string' then
-		-- gen_dd_entry handles this
-	elseif type(func_or_othername) == 'function' then
-		error"bah"
+	function gui.add_dropdown_entry (menutag, name, func_tbl, func_or_othername, arg, tooltiptext)
+		local emtbl = assert(gui.dropdown[menutag])
+
+		if type(func_tbl) == 'table' then
+			-- use it directly
+		elseif func_tbl == nil then
+			-- determine it from the menu tag
+			func_tbl = (menutag:sub(1,3) == 'eoi' and eoi_dropdownfuncs)
+				or (menutag:sub(1,4) == 'hist' and hist_dropdownfuncs)
+				or error("Cannot figure out function table from menu tag name")
+		end
+
+		if type(func_or_othername) == 'string' then
+			-- gen_dd_entry handles this
+		elseif type(func_or_othername) == 'function' then
+			error"bah"
+		end
+
+		-- Insert most new entries right under the title
+		local index
+		if menutag == 'eoi_loot' then
+			index = 3
+		elseif menutag == 'eoi_player' then
+			index = 3
+		elseif menutag == 'eoi_loot_mark' then
+			index = #emtbl + 1
+		else
+			index = 2
+		end
+
+		local ent = gen_dd_entry (name, func_tbl, func_or_othername, arg, tooltiptext)
+		tinsert (emtbl, index, ent)
+
+		if menutag == 'eoi_loot_mark' then
+			ent.notCheckable = nil
+			ent.checked = disposition_is_checked
+		end
+
+		return ent
 	end
-
-	local index
-	if menutag == 'eoi_loot' then
-		index = 2
-	elseif menutag == 'eoi_player' then
-		index = 3
-	else
-		index = 2
-	end
-
-	local ent = gen_dd_entry (name, func_tbl, func_or_othername, arg, tooltiptext)
-	tinsert (emtbl, index, ent)
-	return ent
 end