diff gui.lua @ 86:703bbe61d12d

Proper class coloring in one place.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 21 Jun 2012 21:14:24 +0000
parents c87bf3e756f3
children 9fea75b0927b
line wrap: on
line diff
--- a/gui.lua	Thu Jun 21 19:38:54 2012 +0000
+++ b/gui.lua	Thu Jun 21 21:14:24 2012 +0000
@@ -88,27 +88,6 @@
 -- Similarly for the popup tips on the right side of the window.
 local noob_tips = {}
 
--- Class color support
-local class_colors-- = {}
-do
-	local function fill_out_class_colors()
-		class_colors = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
-		-- If we were dependant on lib-st calling this function (via a
-		-- 'color' field in eoi_st_cols[2]), then this would have to be deep
-		-- copied and an "a=1" field added to each.  But as we have to use
-		-- this ourselves via DoCellUpdate, we can just share tables and
-		-- pass an alpha value manually during cell update.
-		--for class,color in pairs(CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS) do
-		--	class_colors[class] = { r = color.r, g = color.g, b = color.b, a = 1 }
-		--end
-	end
-	fill_out_class_colors()
-	if CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS.RegisterCallback then
-		CUSTOM_CLASS_COLORS:RegisterCallback(fill_out_class_colors)
-	end
-	addon.class_colors = class_colors
-end
-
 do
 	local replacement_colors = {
 		["+"]="|cffffffff",   -- white
@@ -448,6 +427,7 @@
 				local st_entry = new()
 				st_entry.kind = 'hist'
 				st_entry.OLwho = player.name
+				st_entry.OLclass = player.person_class
 				st_entry.cols = dotcols
 				st_entry.itemlink = ilink  -- for onenter and onclick
 				tinsert (st, st_entry)
@@ -856,8 +836,8 @@
 		if gone.kind == 'loot' and IsShiftKeyDown() then
 			local okay,err = addon:_delHistoryEntry (gone)
 			if okay then
-				addon:Print("Removed history entry %s from '%s'.",
-					gone.itemlink, gone.person)
+				addon:Print("Removed history entry %s from %s.",
+					gone.itemlink, addon:colorize(gone.person,gone.person_class))
 			else
 				addon:Print(err)
 			end
@@ -1237,7 +1217,7 @@
 		icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[e.person_class]))
 		icon:Show()
 		cellFrame.text:SetPoint("LEFT", icon, "RIGHT", 1, 0)
-		local color = class_colors[e.person_class]
+		local color = addon.class_colors[e.person_class]
 		cellFrame.text:SetTextColor(color.r,color.g,color.b,1)
 	else
 		if cellFrame.icontexture then
@@ -1527,8 +1507,8 @@
 		local h = _d:GetUserData("DD history entry")
 		local okay,err = addon:_delHistoryEntry (h.cols[2].OLu, h.itemlink)
 		if okay then
-			addon:Print("Removed history entry %s from '%s'.",
-				h.itemlink, h.OLwho)
+			addon:Print("Removed history entry %s from %s.",
+				h.itemlink, addon:colorize(h.OLwho,h.OLclass))
 		else
 			addon:Print(err)
 		end
@@ -1541,8 +1521,8 @@
 		local gone = tremove (addon.history, player_i)
 		assert(gone.name == name)
 		addon:_build_history_names()
-		addon:Print("Removed player '%s' from history (%d total entries).",
-			name, #gone.unique)
+		addon:Print("Removed player %s from history (%d total entries).",
+			addon:colorize(name,gone.person_class), #gone.unique)
 	end,
 }
 local hist_general_dropdown = gen_easymenu_table(