1. #1

    class-coloring text

    going into detail, i have this code to spawn the raid frames
    Code:
    		self:SetSize(38,18)
    			
    			Health:SetSize(38, 18)
    			Health:SetPoint("TOP", self, "TOP")
    			HealthBackground:SetPoint("LEFT", Health:GetStatusBarTexture(), "RIGHT")
    			HealthBackground:SetPoint("RIGHT", Health, "RIGHT")
    			HealthBackground:SetAlpha(1)
    			HealthBackground:SetHeight(Health:GetHeight())
    	
    			Name:SetPoint("LEFT", Health, "LEFT", 2, 0)
    			Name:SetPoint("RIGHT", Health, "RIGHT", -2, 0)
    			self:Tag(Name, '[nameshort]')
    is there any simple way to get the class colors from a table i have defined and color the name/strings on the raid frames accordingly?
    Non ti fidar di me se il cuor ti manca.

  2. #2
    Deleted
    :SetTextColor on the FontString? Also, use RAID_CLASS_COLORS[(select(2,UnitClass(unit)))].

    ---------- Post added 2011-10-26 at 09:16 PM ----------

    If you don't have access to the fontString, use |cffrrggbbTEXT|r

  3. #3
    Below Code is from the LitePanels addon core.lua. Maybe this will help

    local class = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[strupper(lpanels.cinfo.c)]
    local function setcolor(color)
    if color == "CLASS" then
    return class.r, class.g, class.b
    elseif is(color,'string') then
    return strmatch(color, "([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)")
    else return unpack(color) end
    end

    If this does work and you implement as-is, maybe out in a good word for the original author

  4. #4
    I wanted to use the SetTextColor tbh, just when i set up the color all goes wild. Going to try your suggestions, then post results
    Non ti fidar di me se il cuor ti manca.

  5. #5
    Deleted
    Code:
    --assumption: you have a local 'text' containing the string you want to display
    local col = RAID_CLASS_COLORS[(select(2,UnitClass("player")))]
    if col then
        text = ("|cff%02x%02x%02x%s|r"):format(col.r,col.g,col.b,text)
    end

  6. #6
    The local i use is Name displayed above. Thanks again for the help, when i get home from work i'll give a try.

    EDIT: wouldn't a code like this work?
    Code:
    local col = RAID_CLASS_COLORS[(select(2,UnitClass("player")))]
    if col then
      Name:SetTextColor(col.r, col.g, col.b)
    end
    Last edited by Coldkil; 2011-10-27 at 06:24 AM.
    Non ti fidar di me se il cuor ti manca.

  7. #7
    Deleted
    Sure, should work fine - like I said, you only need to use color coded strings if you can't access the FontString for whatever reason.

  8. #8
    It works, but not the way i want. I need to color the text for each frame differently corresponding to the class of the unit. is it possible? Probably i just need to change the "player" part.

    EDIT: works if i put "party1", "party2", etc. I need to do a for cycle to run through the units, is there a method to get the party/raid number of members? Thanks again.

    EDIT 2: got it. for anyone who needs it, the methods GetNumPartyMembers() and GetNumRaidMembers() are just here for this kind of issues
    Last edited by Coldkil; 2011-10-27 at 04:20 PM.
    Non ti fidar di me se il cuor ti manca.

  9. #9
    Deleted
    GetNumPartyMembers() / GetNumRaidMembers()? Not sure I understand the question.

  10. #10
    Best way to explain myself is showing the code

    Code:
    			local num = GetNumPartyMembers()
    			for i = 1, num do
    			  local col = RAID_CLASS_COLORS[(select(2,UnitClass("party"..i)))]
    			  if col then
    			    Name:SetTextColor(col.r, col.g, col.b)
    			  end
    			end
    This way, you get every name on every party frame colored with the class color of the party member. Same way works for raid.

    EDIT: need to put it into a better place (maybe spawn code) because as for now when i log in text stay white, with a reload ui all goes well

    EDIT 2: for raid it doesn't work, it keeps to get the player còass color and you'll get all the names equal. for party all goes well.
    Last edited by Coldkil; 2011-10-27 at 07:23 PM.
    Non ti fidar di me se il cuor ti manca.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •