WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Combo Points Conditional Formating (https://www.wowinterface.com/forums/showthread.php?t=30786)

neverg 02-19-10 06:37 PM

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

wurmfood 02-19-10 08:12 PM

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.

neverg 02-19-10 10:58 PM

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. :p

Freebaser 02-20-10 03:19 AM

Code:

local function updateCombo(self)
    do stuff..
end
...

-- this goes in the layout function
self:RegisterEvent('UNIT_COMBO_POINTS', updateCombo)


neverg 02-20-10 06:32 AM

Quote:

Originally Posted by Freebaser (Post 179241)
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 :D , 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.

Waverian 02-20-10 06:10 PM

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


neverg 02-21-10 12:06 PM

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 :D). Kinda blind to "program" this way.

wurmfood 02-21-10 12:15 PM

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


neverg 02-21-10 12:44 PM

Quote:

Originally Posted by wurmfood (Post 179395)
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! :D 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

Quote:

self:RegisterEvent("UNIT_COMBO_POINTS", UpdateComboPointsFormat)

Awesome! More Quick Feedback to the combo points. :)

Thanks a lot to all that helped me.


All times are GMT -6. The time now is 03:29 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI