Thread Tools Display Modes
02-19-10, 06:37 PM   #1
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Combo Points Conditional Formating

Hey guys! First of all let me thanks Haste and all the developers of oUF Layouts. I've been messing with my oUF Layout, I'm using oUF_Hypocrisy, but I've been changing it so much over time that it doesn't resemble almost anything of Hypocrisy now. Tho I like how the code is organized so it's a nice framework to build my customization around it. Anyway... the question

I'm showing text for the Combo Points. It's working alright. I've searched the old oUF Topic and I've only found reference to Combo Points of a question from Roth, but it had nothing to do with this. So here I am.

Like I was saying I'm displaying the Combo Points with the code bellow. It's working alright, but the colored part is what I want to work but it isn't. I want to display the Combo Points RED if I have 5 CP's on the target. Thing is the text is always in White. I guess it has something to do with the updates or something...


Code:
if unit=="target" then
			if(playerClass=="ROGUE" or playerClass=="DRUID") then
				self.CPoints = self:CreateFontString(nil, 'OVERLAY')
				self.CPoints:SetFont(font, fontsize*3, "OUTLINE")
				self.CPoints:SetPoint('CENTER', self, 'LEFT', -110, 0)	
				self.CPoints:SetShadowOffset(1, -1)
				self.CPoints:SetJustifyH('CENTER')
				
				local ccp = GetComboPoints("target")		
				if ccp == 5 then
					self.CPoints:SetTextColor(1, 0, 0)
				else
					self.CPoints:SetTextColor(0.90, 1, 1)
				end
			end
		end
Hope some of you can help me. Thanks

-greven
  Reply With Quote
02-19-10, 08:12 PM   #2
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
At the time of the layout being put in place, the combo points will always be zero. Strip out the yellow part and register the combo point update event (can't remember it right now) pointing to a function that changes the text color.
  Reply With Quote
02-19-10, 10:58 PM   #3
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Oh I see... I imagined it had to do with the update of the combo points. Going to try to achieve that then... even If I'll have to do some try and error.
  Reply With Quote
02-20-10, 03:19 AM   #4
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Code:
local function updateCombo(self)
     do stuff..
end
...

-- this goes in the layout function
self:RegisterEvent('UNIT_COMBO_POINTS', updateCombo)
  Reply With Quote
02-20-10, 06:32 AM   #5
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Originally Posted by Freebaser View Post
Code:
local function updateCombo(self)
     do stuff..
end
...

-- this goes in the layout function
self:RegisterEvent('UNIT_COMBO_POINTS', updateCombo)
Thanks Freebaser, helpful, I had almost that already , just need to find a way to update the text inside the function since I can't link there the CPoints frame because of scope I guess.
  Reply With Quote
02-20-10, 06:10 PM   #6
Waverian
A Chromatic Dragonspawn
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 188
The first argument of any custom event for oUF is a reference to the frame triggering it.

Code:
local function UpdateComboPoints(self, event, unit)
     --zzz
end
  Reply With Quote
02-21-10, 12:06 PM   #7
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Thanks for the help guys. The below code isn't doing anything, not getting any error, but it simply doesn't change color. Not even if I get 1 2 3 4 combo points. I've set the text to green to test it, nada.

I have this outside the layout function:

Code:
local function UpdateComboPointsFormat(self, event, unit)

		if unit=="target" then
			if(playerClass=="ROGUE" or playerClass=="DRUID") then
				local ccp = GetComboPoints(unit)		
					if ccp == 5 then
						self.CPoints:SetTextColor(1, 0, 0)
					else
						self.CPoints:SetTextColor(0, 0, 1)
					end
			end
		end
end
And this in the layout function:

Code:
			
		if unit=="target" then
			if(playerClass=="ROGUE" or playerClass=="DRUID") then
				self.CPoints = self:CreateFontString(nil, 'OVERLAY')
				self.CPoints:SetFont(font, fontsize*3, "OUTLINE")
				self.CPoints:SetPoint('CENTER', self, 'LEFT', -110, 0)	
				self.CPoints:SetShadowOffset(1, -1)
				self.CPoints:SetJustifyH('CENTER')
				--self.CPoints:SetTextColor(0.90, 1, 1)		
			end
		end

self:RegisterEvent("UNIT_COMBO_POINTS", UpdateComboPointsFormat)

Note the commented, that is what it USED to do, now I want the text to be red when I have 5 combo points.

It Bugs me not to be able to use a debugger (no pun intended ). Kinda blind to "program" this way.

Last edited by neverg : 02-21-10 at 12:21 PM.
  Reply With Quote
02-21-10, 12:15 PM   #8
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
Try this:
Code:
local function UpdateComboPointsFormat(self, event, unit)
	if( self.CPoints ) then
		local ccp = GetComboPoints(unit)		
		if ccp == 5 then
			self.CPoints:SetTextColor(1, 0, 0)
		else
			self.CPoints:SetTextColor(0.90, 1, 1)
		end
	end
end
  Reply With Quote
02-21-10, 12:44 PM   #9
neverg
A Frostmaul Preserver
 
neverg's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2007
Posts: 268
Originally Posted by wurmfood View Post
Try this:
Code:
local function UpdateComboPointsFormat(self, event, unit)
	if( self.CPoints ) then
		local ccp = GetComboPoints(unit)		
		if ccp == 5 then
			self.CPoints:SetTextColor(1, 0, 0)
		else
			self.CPoints:SetTextColor(0.90, 1, 1)
		end
	end
end
Awesome! It works without errors. It was working but it was giving me errors because it was indexing CPoints even if the conditions weren't met in the IF. Now it's working without errors! Thanks!

So the final code to "color" combo points is, if anyone interested:

Code:
local function UpdateComboPointsFormat(self, event, unit)
						
						
		if (self.CPoints) then
				local ccp = GetComboPoints(unit,'target')		
					if ccp == 1 then
						self.CPoints:SetTextColor(241/255, 241/255, 241/255)
					elseif ccp == 2 then
						self.CPoints:SetTextColor(241/255, 241/255, 241/255)
					elseif ccp == 3 then
						self.CPoints:SetTextColor(211/255, 241/255, 11/255)
					elseif ccp == 4 then
						self.CPoints:SetTextColor(241/255, 141/255, 11/255)
					elseif ccp == 5 then
						self.CPoints:SetTextColor(241/255, 11/255, 11/255)
					end
			
		end
end
And the Register Event

self:RegisterEvent("UNIT_COMBO_POINTS", UpdateComboPointsFormat)

Awesome! More Quick Feedback to the combo points.

Thanks a lot to all that helped me.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Combo Points Conditional Formating

Thread Tools
Display Modes

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