diff core.lua @ 118:ec5174529e0f

Make more use of g_loot.raiders in the GUI rather than calling GRRI each time.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 16 Aug 2012 23:04:29 -0400
parents fc2ff128835a
children fb4bda3ad05c
line wrap: on
line diff
--- a/core.lua	Thu Aug 16 20:00:03 2012 -0400
+++ b/core.lua	Thu Aug 16 23:04:29 2012 -0400
@@ -2173,6 +2173,37 @@
 	return self._find_next_after, filter_kind, 0
 end
 
+-- Iterate through g_loot.raiders in sorted (alphabetical/collated) order.  If
+-- USE_FULLNAME then the realmname is appended.  If ONLINE_FILTER is present,
+-- then only raider entries with a matching 'online' key are included.  Loop
+-- variables are a running count, the raider name, and the corresponding entry
+-- from g_loot.raiders.
+do
+	local function nextr (list, index)
+		index = index + 1
+		local name = list[index]
+		if not name then
+			flib.del(list)
+			return nil
+		end
+		return index, name, list.__safety[name]
+	end
+
+	function addon:sorted_raiders_iter (use_fullname_p, opt_online_filter)
+		local t = flib.new()
+		for name,info in next, g_loot.raiders do
+			if (not opt_online_filter) or (info.online == opt_online_filter) then
+				-- this is not exactly "A?B:C" semantics, but it is exactly
+				-- the behavior we want when fname is not present
+				tinsert (t, use_fullname_p and info.fname or name)
+			end
+		end
+		table.sort(t)
+		t.__safety = g_loot.raiders
+		return nextr, t, 0
+	end
+end
+
 do
 	local itt
 	local function create()
@@ -2245,6 +2276,9 @@
 	if possible_st then
 		possible_st:SetData(g_loot_wrapper)
 	end
+	-- Make sure we have a current .raiders array, since other dropdowns and
+	-- whatnot depend on that information.
+	self:CheckRoster()
 
 	self.status_text = ("%s(r%s) communicating as ident %s commrev %s"):
 		format (self.version, self.revision, self.ident, self.commrev)