Quantcast

Merge branch 'master' of git.wowace.com:wow/arl/mainline

pompachomp [03-22-10 - 15:25]
Merge branch 'master' of git.wowace.com:wow/arl/mainline
Filename
Colour.lua
Constants.lua
Frame.lua
diff --git a/Colour.lua b/Colour.lua
index dc36bbb..d15d153 100644
--- a/Colour.lua
+++ b/Colour.lua
@@ -22,27 +22,21 @@ local addon				= LibStub("AceAddon-3.0"):GetAddon(MODNAME)

 --Colour constants
 local RED	= "ff0000"
---local ORANGE	= "ff7f00"
 local ORANGE	= "ff8040"
 local YELLOW	= "ffff00"
---local GREEN	= "00ff00"
 local GREEN	= "40bf40"
 local WHITE	= "ffffff"
+
 local COPPER	= "eda55f"
 local SILVER	= "c7c7cf"
 local GOLD	= "ffd700"
+
 local PURPLE	= "9980CC"
 local BLUE	= "0000ff"
 local CYAN	= "00ffff"
 local BLACK	= "000000"
 local GREY	= "666666"
---local MIDGREY	= "858585"
 local MIDGREY	= "808080"
-local NEUTRAL	= "bfbfbf"
-local FRIENDLY	= WHITE
-local HONORED	= "00ff00"
-local REVERED	= "3f66e5"
-local EXALTED	= "9933cc"

 local TRAINER	= "d9cb9e"
 local VENDOR	= "aad372"
@@ -51,14 +45,6 @@ local REP	= "ff7c0a"
 local SEASON	= "80590e"
 local MOBDROP	= "ffffc0"

-local POOR	= "919191"
-local COMMON	= WHITE
-local UNCOMMON	= "00A900"
-local RARE	= "0062C3"
-local EPIC	= "B343FF"
-local LEGENDARY	= "FA9900"
-local ARTIFACT	= "e5cc80"
-
 local HIGH	= WHITE
 local NORMAL	= "ffd100"

@@ -67,41 +53,10 @@ local ALLIANCE	= "00ffff"
 ----------------------------------------------------------------------
 --Text colourization functions
 ----------------------------------------------------------------------
-function addon:RGBtoHEX(r,g,b)
-	return string.format("%2x%2x%2x", r*255, g*255, b*255)
-end
-

 -- Changes any string of text to the specified hex colour
 function addon:Colourize(hexColour, text)
-
 	return "|cff" .. tostring(hexColour or 'ffffff') .. tostring(text) .. "|r"
-
-end
-
--- Converts text to Neutral Colour
-function addon:Neutral(text)
-	return self:Colourize(NEUTRAL, text)
-end
-
--- Converts text to Friendly Colour
-function addon:Friendly(text)
-	return self:Colourize(FRIENDLY, text)
-end
-
--- Converts text to Honored Colour
-function addon:Honored(text)
-	return self:Colourize(HONORED, text)
-end
-
--- Converts text to Revered Colour
-function addon:Revered(text)
-	return self:Colourize(REVERED, text)
-end
-
--- Converts text to Exalted Colour
-function addon:Exalted(text)
-	return self:Colourize(EXALTED, text)
 end

 function addon:Horde(text)
@@ -140,53 +95,6 @@ function addon:MobDrop(text)
 	return self:Colourize(MOBDROP, text)
 end

--- Rarity Colors
-function addon:Poor(text)
-	return self:Colourize(POOR, text)
-end
-
-function addon:Common(text)
-	return self:Colourize(COMMON, text)
-end
-
-function addon:Uncommon(text)
-	return self:Colourize(UNCOMMON, text)
-end
-
-function addon:Rare(text)
-	return self:Colourize(RARE, text)
-end
-
-function addon:Epic(text)
-	return self:Colourize(EPIC, text)
-end
-
-function addon:Legendary(text)
-	return self:Colourize(LEGENDARY, text)
-end
-
-function addon:Artifact(text)
-	return self:Colourize(ARTIFACT, text)
-end
-
-function addon:RarityColor(rarityColor, text)
-	if (rarityColor == 1) then
-		return self:Colourize(POOR, text)
-	elseif (rarityColor == 2) then
-		return self:Colourize(COMMON, text)
-	elseif (rarityColor == 3) then
-		return self:Colourize(UNCOMMON, text)
-	elseif (rarityColor == 4) then
-		return self:Colourize(RARE, text)
-	elseif (rarityColor == 5) then
-		return self:Colourize(EPIC, text)
-	elseif (rarityColor == 6) then
-		return self:Colourize(LEGENDARY, text)
-	else
-		return self:Colourize(ARTIFACT, text)
-	end
-end
-
 -- Converts text to Red
 function addon:Red(text)
 	return self:Colourize(RED, text)
@@ -267,48 +175,28 @@ end
 -------------------------------------------------------------------------------
 do
 	local COLOR_NAMES = {
-		["NEUTRAL"]	= "|cff"..NEUTRAL,
-		["FRIENDLY"]	= "|cff"..FRIENDLY,
-		["HONORED"]	= "|cff"..HONORED,
-		["REVERED"]	= "|cff"..REVERED,
-		["EXALTED"]	= "|cff"..EXALTED,
-
-		["TRAINER"]	= "|cff"..TRAINER,
-		["VENDOR"]	= "|cff"..VENDOR,
-		["QUEST"]	= "|cff"..QUEST,
-		["REP"]		= "|cff"..REP,
-		["SEASON"]	= "|cff"..SEASON,
-		["MOBDROP"]	= "|cff"..MOBDROP,
-
-		["POOR"]	= "|cff"..POOR,
-		["COMMON"]	= "|cff"..COMMON,
-		["UNCOMMON"]	= "|cff"..UNCOMMON,
-		["RARE"]	= "|cff"..RARE,
-		["EPIC"]	= "|cff"..EPIC,
-		["LEGENDARY"]	= "|cff"..LEGENDARY,
-		["ARTIFACT"]	= "|cff"..ARTIFACT,
-
-		["HORDE"]	= "|cff"..HORDE,
-		["ALLIANCE"]	= "|cff"..ALLIANCE,
-
-		["BLACK"]	= "|cff"..BLACK,
-		["ORANGE"]	= "|cff"..ORANGE,
-		["GREEN"]	= "|cff"..GREEN,
-		["YELLOW"]	= "|cff"..YELLOW,
-		["GREY"]	= "|cff"..GREY,
-		["MIDGREY"]	= "|cff"..MIDGREY,
-		["RED"]		= "|cff"..RED,
-
-		["HIGH"]	= "|cff"..HIGH,
+		["TRAINER"]	= TRAINER,
+		["VENDOR"]	= VENDOR,
+		["QUEST"]	= QUEST,
+		["REP"]		= REP,
+		["SEASON"]	= SEASON,
+		["MOBDROP"]	= MOBDROP,
+
+		["HORDE"]	= HORDE,
+		["ALLIANCE"]	= ALLIANCE,
+
+		["BLACK"]	= BLACK,
+		["ORANGE"]	= ORANGE,
+		["GREEN"]	= GREEN,
+		["YELLOW"]	= YELLOW,
+		["GREY"]	= GREY,
+		["MIDGREY"]	= MIDGREY,
+		["RED"]		= RED,
+
+		["HIGH"]	= HIGH,
 	}

 	function addon:hexcolor(colorstring)
-		local color = COLOR_NAMES[colorstring]
-
-		if not color then
-			return "|cff"..NORMAL
-		end
-
-		return color
+		return "|cff"..(COLOR_NAMES[colorstring] or NORMAL)
 	end
 end	-- do
diff --git a/Constants.lua b/Constants.lua
index 0aa9aa7..33ec543 100644
--- a/Constants.lua
+++ b/Constants.lua
@@ -260,3 +260,22 @@ private.faction_strings = {
 	[1119]	= "HODIR",
 	[1156]	= "ASHEN_VERDICT",
 }
+
+-------------------------------------------------------------------------------
+-- Colors.
+-------------------------------------------------------------------------------
+local function RGBtoHEX(r, g, b)
+	return string.format("%2x%2x%2x", r * 255, g * 255, b * 255)
+end
+
+local function GetColorsFromTable(dict)
+	return dict.r, dict.g, dict.b
+end
+
+private.reputation_colors = {
+	["exalted"]	= RGBtoHEX(GetColorsFromTable(_G.QuestDifficultyColors["impossible"])),
+	["revered"]	= RGBtoHEX(GetColorsFromTable(_G.QuestDifficultyColors["verydifficult"])),
+	["honored"]	= RGBtoHEX(GetColorsFromTable(_G.QuestDifficultyColors["difficult"])),
+	["friendly"]	= RGBtoHEX(GetColorsFromTable(_G.QuestDifficultyColors["standard"])),
+	["neutral"]	= RGBtoHEX(GetColorsFromTable(_G.QuestDifficultyColors["trivial"])),
+}
diff --git a/Frame.lua b/Frame.lua
index e68036c..100804f 100644
--- a/Frame.lua
+++ b/Frame.lua
@@ -453,6 +453,13 @@ do
 end	-- do

 -------------------------------------------------------------------------------
+-- Common to the tooltip and MainPanel list entries.
+-------------------------------------------------------------------------------
+local function SetTextColor(color_code, text)
+	return string.format("|cff%s%s|r", color_code or "ffffff", text)
+end
+
+-------------------------------------------------------------------------------
 -- Tooltip functions and data.
 -------------------------------------------------------------------------------
 local spell_tip = CreateFrame("GameTooltip", "arlSpellTooltip", UIParent, "GameTooltipTemplate")
@@ -586,7 +593,7 @@ do
 				faction = FACTION_ALLIANCE
 			end
 		else
-			color = addon:hexcolor("NEUTRAL")
+			color = "|cff"..private.reputation_colors["neutral"]
 			faction = FACTION_NEUTRAL
 			display_tip = true
 		end
@@ -796,6 +803,8 @@ do
 					ttAdd(0, -1, 0, SEASONAL_CATEGORY, color_1, private.seasonal_list[id_num].name, color_1)
 				end
 			elseif acquire_type == A.REPUTATION then
+				local rep_color = private.reputation_colors
+
 				for rep_id, rep_info in pairs(acquire_info) do
 					for rep_level, level_info in pairs(rep_info) do
 						for vendor_id in pairs(level_info) do
@@ -811,19 +820,19 @@ do

 								if rep_level == 0 then
 									rep_str = FACTION_NEUTRAL
-									color_1 = addon:hexcolor("NEUTRAL")
+									color_1 = "|cff"..rep_color["neutral"]
 								elseif rep_level == 1 then
 									rep_str = BFAC["Friendly"]
-									color_1 = addon:hexcolor("FRIENDLY")
+									color_1 = "|cff"..rep_color["friendly"]
 								elseif rep_level == 2 then
 									rep_str = BFAC["Honored"]
-									color_1 = addon:hexcolor("HONORED")
+									color_1 = "|cff"..rep_color["honored"]
 								elseif rep_level == 3 then
 									rep_str = BFAC["Revered"]
-									color_1 = addon:hexcolor("REVERED")
+									color_1 = "|cff"..rep_color["revered"]
 								else
 									rep_str = BFAC["Exalted"]
-									color_1 = addon:hexcolor("EXALTED")
+									color_1 = "|cff"..rep_color["exalted"]
 								end
 								ttAdd(1, -2, false, rep_str, color_1, rep_vendor.name, color_2)

@@ -2492,6 +2501,7 @@ do
 		end
 		local recipe_id = self.entries[orig_index].recipe_id
 		local obtain_filters = addon.db.profile.filters.obtain
+		local rep_color = private.reputation_colors

 		for acquire_type, acquire_info in pairs(private.recipe_list[recipe_id].acquire_data) do
 			if acquire_type == A.TRAINER and obtain_filters.trainer then
@@ -2510,7 +2520,7 @@ do
 						elseif trainer.faction == FACTION_ALLIANCE then
 							nStr = addon:Alliance(trainer.name)
 						else
-							nStr = addon:Neutral(trainer.name)
+							nStr = SetTextColor(rep_color["neutral"], trainer.name)
 						end
 						t.text = pad .. addon:Trainer(L["Trainer"] .. " : ") .. nStr

@@ -2550,7 +2560,7 @@ do
 						elseif vendor.faction == FACTION_ALLIANCE then
 							nStr = addon:Alliance(vendor.name)
 						else
-							nStr = addon:Neutral(vendor.name)
+							nStr = SetTextColor(rep_color["neutral"], vendor.name)
 						end
 						t.text = pad .. addon:Vendor(L["Vendor"] .. " : ") .. nStr

@@ -2613,7 +2623,7 @@ do
 						elseif quest.faction == FACTION_ALLIANCE then
 							nStr = addon:Alliance(quest.name)
 						else
-							nStr = addon:Neutral(quest.name)
+							nStr = SetTextColor(rep_color["neutral"], quest.name)
 						end
 						t.text = pad .. addon:Quest(L["Quest"] .. " : ") .. nStr

@@ -2651,11 +2661,11 @@ do
 				-- Rep_vendor - VendorID
 				if not faction_strings then
 					faction_strings = {
-						[0] = addon:Neutral(FACTION_NEUTRAL .. " : "),
-						[1] = addon:Friendly(BFAC["Friendly"] .. " : "),
-						[2] = addon:Honored(BFAC["Honored"] .. " : "),
-						[3] = addon:Revered(BFAC["Revered"] .. " : "),
-						[4] = addon:Exalted(BFAC["Exalted"] .. " : ")
+						[0] = SetTextColor(rep_color["neutral"], FACTION_NEUTRAL .. " : "),
+						[1] = SetTextColor(rep_color["friendly"], BFAC["Friendly"] .. " : "),
+						[2] = SetTextColor(rep_color["honored"], BFAC["Honored"] .. " : "),
+						[3] = SetTextColor(rep_color["revered"], BFAC["Revered"] .. " : "),
+						[4] = SetTextColor(rep_color["exalted"], BFAC["Exalted"] .. " : ")
 					}
 				end

@@ -2680,7 +2690,7 @@ do
 								elseif rep_vendor.faction == FACTION_ALLIANCE then
 									nStr = addon:Alliance(rep_vendor.name)
 								else
-									nStr = addon:Neutral(rep_vendor.name)
+									nStr = SetTextColor(rep_color["neutral"], rep_vendor.name)
 								end
 								t = AcquireTable()
 								t.recipe_id = recipe_id
@@ -2750,7 +2760,7 @@ do
 						elseif vendor.faction == FACTION_ALLIANCE then
 							nStr = addon:Alliance(vendor.name)
 						else
-							nStr = addon:Neutral(vendor.name)
+							nStr = SetTextColor(rep_color["neutral"], vendor.name)
 						end
 						t.text = pad .. addon:Vendor(L["Vendor"] .. " : ") .. nStr