diff core.lua @ 93:ea20a28327b5

More tweaks in preparation for MoP.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Wed, 18 Jul 2012 07:42:16 +0000
parents 01cfbfa96dd6
children db1d5d09e5f5
line wrap: on
line diff
--- a/core.lua	Tue Jul 17 03:24:36 2012 +0000
+++ b/core.lua	Wed Jul 18 07:42:16 2012 +0000
@@ -327,8 +327,13 @@
 do
 	local cc = {}
 	local function extract (color_info)
-		local hex = ("|cff%.2x%.2x%.2x"):format(255*color_info.r,
-			255*color_info.g, 255*color_info.b)
+		local hex
+		if color_info.colorStr then   -- MoP
+			hex = "|c" .. color_info.colorStr
+		else                          -- pre-MoP
+			hex = ("|cff%.2x%.2x%.2x"):format(255*color_info.r,
+				255*color_info.g, 255*color_info.b)
+		end
 		return { r=color_info.r, g=color_info.g, b=color_info.b, a=1, hex=hex }
 	end
 	local function fill_out_class_colors()
@@ -340,8 +345,9 @@
 	if CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS.RegisterCallback then
 		CUSTOM_CLASS_COLORS:RegisterCallback(fill_out_class_colors)
 	end
-	fill_out_class_colors()
-	addon.class_colors = cc
+	addon.class_colors = cc                               -- this stays around
+	addon.fill_out_class_colors = fill_out_class_colors   -- this doesn't
+
 	-- What I really want is to have the hooked :Print understand a special
 	-- format specifier like "%Cs" and do the colorizing automatically.
 	function addon:colorize (text, class)
@@ -379,6 +385,7 @@
 local pprint, tabledump = addon.pprint, flib.tabledump
 local CopyTable = _G.CopyTable
 local GetNumRaidMembers = _G.GetNumGroupMembers or _G.GetNumRaidMembers
+local IsInRaid = _G.IsInRaid or (function() return GetNumRaidMembers() > 0 end)
 -- En masse forward decls of symbols defined inside local blocks
 local _register_bossmod, makedate, create_new_cache, _init, _log
 local _history_by_loot_id, _setup_unique_replace, _unavoidable_collision
@@ -501,13 +508,13 @@
 	if (GetLFGMode()) and (GetLFGModeType() == 'raid') then
 		t,r = 'LFR', 25
 	elseif diffcode == 1 then
-		if GetNumRaidMembers() > 0 then
+		if IsInRaid() then
 			t,r = "10",10
 		else
 			t,r = "5",5
 		end
 	elseif diffcode == 2 then
-		if GetNumRaidMembers() > 0 then
+		if IsInRaid() then
 			t,r = "25",25
 		else
 			t,r = "5h",5
@@ -918,6 +925,13 @@
 		end
 	end
 
+	-- Copy these over once, now that other addons have mostly loaded.  Any
+	-- future tweaks via CUSTOM_CLASS_COLORS will trigger the same callback.
+	if addon.fill_out_class_colors then
+		addon.fill_out_class_colors()
+		addon.fill_out_class_colors = nil
+	end
+
 	while opts.keybinding do
 		if InCombatLockdown() then
 			local reload = self.format_hypertext ([[the options tab]],
@@ -1711,7 +1725,7 @@
 	self:RegisterEvent("PLAYER_ENTERING_WORLD",
 		function() self:ScheduleTimer("RAID_ROSTER_UPDATE", 5, "PLAYER_ENTERING_WORLD") end)
 	self.popped = true
-	if GetNumRaidMembers() > 0 then
+	if IsInRaid() then
 		self.dprint('flow', ">:Activate calling RRU")
 		self:RAID_ROSTER_UPDATE("Activate")
 	elseif self.debug.notraid then
@@ -1925,7 +1939,7 @@
 end
 
 function addon:_check_version (otherrev)
-	self.dprint('comm', "revchecking against", otherrev)
+	self.dprint('comm', version_large, "revchecking against", otherrev)
 	otherrev = tonumber(otherrev)
 	if otherrev == version_large then
 		-- normal case