Advertisement
Guest User

NameplateColors.lua

a guest
Jul 23rd, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. -- Author: Ketho (EU-Boulderfist)
  2. -- License: Public Domain
  3.  
  4. -- friendly nameplate healthbar class colors             (i have disabled this)
  5. DefaultCompactNamePlateFriendlyFrameOptions.useClassColors = false
  6.  
  7. -- enemy nameplate healthbar hostile colors               (i have enabled this)
  8. SetCVar("ShowClassColorInNameplate", 0)
  9. C_Timer.After(.1, function() -- wait and override any enabled cvar
  10.     DefaultCompactNamePlateEnemyFrameOptions.useClassColors = true
  11. end)
  12.  
  13. local CLASS_COLORS = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS
  14. local pvp = {
  15.     Alliance = "\124TInterface/PVPFrame/PVP-Currency-Alliance:16\124t",
  16.     Horde = "\124TInterface/PVPFrame/PVP-Currency-Horde:16\124t",
  17. }
  18.  
  19. -- friendly/enemy nameplate name colors
  20. hooksecurefunc("CompactUnitFrame_UpdateName", function(frame)
  21.     if not ShouldShowName(frame) then
  22.         frame.name:Hide()
  23.     else
  24.         frame.name:SetText(GetUnitName(frame.unit, true))
  25.  
  26.         if CompactUnitFrame_IsTapDenied(frame) then
  27.             -- Use grey if not a player and can't get tap on unit
  28.             frame.name:SetVertexColor(0.5, 0.5, 0.5)
  29.         elseif frame.optionTable.colorNameBySelection then
  30.             -- color players without somehow affecting anything else
  31.             if UnitIsPlayer(frame.unit) then
  32.                 local name = GetUnitName(frame.unit) -- dont include realm name asterisk for players from the same connected realm
  33.                 local isPVP = UnitIsPVP(frame.unit) -- flagged for pvp
  34.                 local faction = UnitFactionGroup(frame.unit)
  35.                
  36.                 frame.name:SetText(isPVP and pvp[faction]..name or name)
  37.                 -- an enemy could also be from the same faction in ffa/arena/duel
  38.                 if UnitIsEnemy("player", frame.unit) then
  39.                     frame.name:SetVertexColor(1.0, 1.0, 1.0) -- friendly, white         (changed enemy to white)
  40.                 else
  41.                     local _, class = UnitClass(frame.unit)
  42.                     local color = CLASS_COLORS[class]
  43.                     frame.name:SetVertexColor(color.r, color.g, color.b) -- enemy, class colors   (changed freindly to class colors)
  44.                 end
  45.             elseif frame.optionTable.considerSelectionInCombatAsHostile and CompactUnitFrame_IsOnThreatListWithPlayer(frame.displayedUnit) then
  46.                 frame.name:SetVertexColor(1.0, 0.0, 0.0)
  47.             else
  48.                 frame.name:SetVertexColor(UnitSelectionColor(frame.unit, frame.optionTable.colorNameWithExtendedColors))
  49.             end
  50.         end
  51.  
  52.         frame.name:Show()
  53.     end
  54. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement