Thread Tools Display Modes
07-21-10, 08:55 PM   #1
Unkn
Premium Member
 
Unkn's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 258
Question about coloring background...

I am trying to set class color to the backdrop of my hp. Trying to match my oUF layout to my grid. Which is set grey until there is a deficit hp then goes class colored. Right now everyone has bright blue background to their hp. Which is well an improvement over the white or black I was getting, but obviously not right.

Code is as follows. Pulled set points out because its just set points...

Code:
   local hp = CreateFrame("StatusBar", nil, self)
   hp:SetStatusBarTexture(statusbartexture)
   hp:SetHeight(hp_height)
   hp:SetStatusBarColor(0.15, 0.15, 0.15) 
     if unit == "player" then
      ....
    elseif unit == "target" then
      .... 
    else
       .....
    end
        hp:SetBackdrop({bgFile="Interface\\AddOns\\oUF_GearedRedux\\StatusBar\\Minimalistv"})
   hp.colorDisconnected = true
   hp.colorClass = false
   hp.colorClassPet = false
   hp.frequentUpdates = true
   self.Health = hp
   
   
-- set health background color
	local color = RAID_CLASS_COLORS[select(2,  UnitClass("unit"))]	
	if UnitIsPlayer("player") and color then
		hp:SetBackdropColor(color.r, color.g, color.b, 1)
	else
		local r, g, b = UnitSelectionColor("unit")
		hp:SetBackdropColor(r, g, b, 1)	
	end
Thats what I've got. Bright blue backdrop..... Any suggestions? ( blue is friendly? reaction type I believe. So guess thats working. But I want that for npcs and the like. For any player I want class colored.)
Attached Thumbnails
Click image for larger version

Name:	bluebgofdoom.jpeg
Views:	724
Size:	70.9 KB
ID:	4635  
__________________
"I'm very feminine. And I'll beat the crap out of ANYONE who disagrees!"

Last edited by Unkn : 07-21-10 at 09:02 PM. Reason: edited for typo
  Reply With Quote
07-21-10, 09:26 PM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
A PostUpdateHealth function would do it. I'm using one to create class and reaction (for npcs) coloured backgrounds for oUF_Nivea.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
07-21-10, 09:45 PM   #3
Unkn
Premium Member
 
Unkn's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 258
Originally Posted by Dawn
A PostUpdateHealth function would do it.
Now its back to the white/grey. Still not working


Code:
	local PostUpdateHealth = function(unit, min, max)
-- set health background color
		local color = RAID_CLASS_COLORS[select(2,  UnitClass("unit"))]	
		if UnitIsPlayer("player") and color then
			hp:SetBackdropColor(color.r, color.g, color.b, .5)
		else
			local r, g, b = UnitSelectionColor("unit")
			hp:SetBackdropColor(r, g, b, .5)	
		end
	end
__________________
"I'm very feminine. And I'll beat the crap out of ANYONE who disagrees!"

Last edited by Unkn : 07-21-10 at 11:47 PM.
  Reply With Quote
07-21-10, 11:51 PM   #4
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Originally Posted by Unkn View Post
Code:
	local PostUpdateHealth = function(unit, min, max)
-- set health background color
		local color = RAID_CLASS_COLORS[select(2,  UnitClass("unit"))]	
		if UnitIsPlayer("player") and color then
			hp:SetBackdropColor(color.r, color.g, color.b, .5)
		else
			local r, g, b = UnitSelectionColor("unit")
			hp:SetBackdropColor(r, g, b, .5)	
		end
	end
I think you have a little problem in you if-clause, cause you're only checking, if the player is a player-controlled character... Here's the function in the API.
But I think some other function calls are false, aswell, since you're passing strings to functions several times, but you want to pass the unit-variable. And I don't really understand your call to UnitSelectionColor (not in the API-documentation, so I don't know what it should do).

Code:
	local PostUpdateHealth = function(unit, min, max)
-- set health background color
		local color = RAID_CLASS_COLORS[select(2,  UnitClass(unit))]	
		if (UnitIsPlayer(unit) and color) then
			hp:SetBackdropColor(color.r, color.g, color.b, .5)
		else
			local r, g, b = UnitSelectionColor(unit)
			hp:SetBackdropColor(r, g, b, .5)	
		end
	end
You can try this one, but I'm at work, so it's untested.
  Reply With Quote
07-22-10, 12:31 AM   #5
Unkn
Premium Member
 
Unkn's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 258
I've got to be doing something wrong elsewhere because none of it is working. I'm not getting any errors, just showing no color at all now. Its just the base color of the bg file.
__________________
"I'm very feminine. And I'll beat the crap out of ANYONE who disagrees!"
  Reply With Quote
07-22-10, 01:28 AM   #6
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Ahh, missed the scoping...
Code:
	local PostUpdateHealth = function(unit, min, max)
-- set health background color
		local color = RAID_CLASS_COLORS[select(2,  UnitClass(unit))]	
		if (UnitIsPlayer(unit) and color) then
			self.Health:SetBackdropColor(color.r, color.g, color.b, .5)
		else
			local r, g, b = UnitSelectionColor(unit)
			self.Health:SetBackdropColor(r, g, b, .5)	
		end
	end
Still untested
  Reply With Quote
07-22-10, 01:46 AM   #7
Unkn
Premium Member
 
Unkn's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 258
Okay so i went and got frustrated.

Code:
 	-- hp bg
	hpbg = hp:CreateTexture(nil, "BACKGROUND")
	hpbg:SetAllPoints(hp)
	hpbg:SetTexture("Interface\\AddOns\\oUF_GearedRedux\\StatusBar\\Minimalistv")
	hp.bg = hpbg
	local _, class = UnitClass("player");
	if class == "WARRIOR" then
		self.Health.bg:SetVertexColor(0.95, 0.23, 0.23, .75)
	elseif class == "PRIEST" then
		self.Health.bg:SetVertexColor(1, 0.96, 0.98, .75)
	elseif class == "MAGE" then
		self.Health.bg:SetVertexColor(0.00, 1, 1, .75)
	elseif class == "DRUID" then
		self.Health.bg:SetVertexColor(1, 0.49, 0.04, .75)
	elseif class == "PALADIN" then
		self.Health.bg:SetVertexColor(0.92, 0.22, 0.46, .75)
	elseif class == "HUNTER" then
		self.Health.bg:SetVertexColor(0.33, 0.86, 0.00, .75)
	elseif class == "ROGUE" then
		self.Health.bg:SetVertexColor(1, 0.94, 0.16, .75)
	elseif class == "SHAMAN" then
		self.Health.bg:SetVertexColor(0.13, 0.42, 1, .75)
	elseif class == "WARLOCK" then
		self.Health.bg:SetVertexColor(0.36, 0.18, 1, .75)
	end
Haha... It colors the background, my toons color. Its a step in the right direction? maybe... but now everything has the background color of the class im playing. whatever atm I can deal with that. I need to figure out how to fix that now.

Took a new screenshot so you could see what I mean. **note, im not trying to get ouf to change the hp status bar to class colored, just the background to be colored the units class type**
Attached Thumbnails
Click image for larger version

Name:	hahaplayerclasscoloredbg.jpg
Views:	704
Size:	35.2 KB
ID:	4636  
__________________
"I'm very feminine. And I'll beat the crap out of ANYONE who disagrees!"

Last edited by Unkn : 07-22-10 at 01:51 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Question about coloring background...


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off