View Single Post
06-06-17, 04:05 AM   #1
siweia
A Flamescale Wyrmkin
 
siweia's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 126
How to set an unique style for Player-nameplate in ouf?

Hi all, I just create a style for all the nameplates, but it also changes playerplate.
Is there anyway to leave the playerplate alone?

Lua Code:
  1. local function UpdateColor(self, unit)
  2.     local name = GetUnitName(unit, false) or UNKNOWN
  3.     local status = UnitThreatSituation("player", unit) or false
  4.     local r, g, b
  5.  
  6.     if not UnitIsConnected(unit) then
  7.         r, g, b = .7, .7, .7
  8.     else
  9.         if CustomUnits and CustomUnits[name] then
  10.             r, g, b = 0, .8, .3
  11.         elseif UnitIsPlayer(unit) and UnitReaction(unit, "player") >= 5 then
  12.             if NDuiDB["Nameplate"]["FriendlyCC"] then
  13.                 r, g, b = B.UnitColor(unit)
  14.             else
  15.                 r, g, b = .3, .3, 1
  16.             end
  17.         elseif UnitIsPlayer(unit) and UnitReaction(unit, "player") <= 4 and NDuiDB["Nameplate"]["HostileCC"] then
  18.             r, g, b = B.UnitColor(unit)
  19.         elseif UnitIsTapDenied(unit) and not UnitPlayerControlled(unit) then
  20.             r, g, b = .6, .6, .6
  21.         else
  22.             r, g, b = UnitSelectionColor(unit, true)
  23.             if status and (NDuiDB["Nameplate"]["TankMode"] or DB.Role == "Tank") then
  24.                 if status == 3 then
  25.                     r, g, b = 1, 0, 1
  26.                 elseif status == 2 or status == 1 then
  27.                     r, g, b = 1, .8, 0
  28.                 end
  29.             end
  30.         end
  31.     end
  32.  
  33.     if r or g or b then
  34.         self:SetStatusBarColor(r, g, b)
  35.     end
  36.  
  37.     if not NDuiDB["Nameplate"]["TankMode"] and DB.Role ~= "Tank" then
  38.         if status and status == 3 then
  39.             self.Shadow:SetBackdropBorderColor(1, 0, 0)
  40.         elseif status and (status == 2 or status == 1) then
  41.             self.Shadow:SetBackdropBorderColor(1, 1, 0)
  42.         else
  43.             self.Shadow:SetBackdropBorderColor(0, 0, 0)
  44.         end
  45.     else
  46.         self.Shadow:SetBackdropBorderColor(0, 0, 0)
  47.     end
  48. end
  49.  
  50. local function UpdateThreatColor(self, event, unit)
  51.     if(unit ~= self.unit) then return end
  52.     local element = self.Health
  53.     unit = unit or self.unit
  54.  
  55.     UpdateColor(element, unit)
  56. end
  57.  
  58. local function UpdateTargetMark(self)
  59.     local mark = self.targetMark
  60.     if not mark then return end
  61.  
  62.     if UnitIsUnit(self.unit, "target") and not UnitIsUnit(self.unit, "player") then
  63.         mark:Show()
  64.     else
  65.         mark:Hide()
  66.     end
  67. end
  68.  
  69. lib.CreateNPs = function(self, unit)
  70.     self.mystyle = "nameplate"
  71.     if unit:match("nameplate") then
  72.         self:SetSize(NDuiDB["Nameplate"]["Width"] * 1.4, NDuiDB["Nameplate"]["Height"])
  73.         self:SetPoint("CENTER", 0, -3)
  74.  
  75.         local health = CreateFrame("StatusBar", nil, self)
  76.         health:SetAllPoints()
  77.         B.CreateSB(health)
  78.         B.SmoothBar(health)
  79.         self.Health = health
  80.         self.Health.frequentUpdates = true
  81.         self.Health.UpdateColor = UpdateColor
  82.  
  83.         lib.gen_hpstrings(self)
  84.         lib.gen_castbar(self)
  85.         lib.gen_RaidMark(self)
  86.         lib.HealPrediction(self)
  87.         lib.createAuras(self)
  88.  
  89.         self.power = B.CreateFS(self, 15, "", false, "LEFT", 0, 0)
  90.         self.power:SetPoint("LEFT", self, "RIGHT", 2, 0)
  91.         self:Tag(self.power, "[nppp]")
  92.  
  93.         if NDuiDB["Nameplate"]["Arrow"] then
  94.             local arrow = self:CreateTexture(nil, "OVERLAY")
  95.             arrow:SetSize(50, 50)
  96.             arrow:SetTexture(DB.arrowTex)
  97.             arrow:SetPoint("BOTTOM", self, "TOP", 0, 14)
  98.             arrow:Hide()
  99.             self.targetMark = arrow
  100.         else
  101.             local glow = CreateFrame("Frame", nil, self)
  102.             glow:SetPoint("TOPLEFT", -5, 5)
  103.             glow:SetPoint("BOTTOMRIGHT", 5, -5)
  104.             glow:SetBackdrop({edgeFile = DB.glowTex, edgeSize = 4})
  105.             glow:SetBackdropBorderColor(1, 1, 1)
  106.             glow:SetFrameLevel(0)
  107.             glow:Hide()
  108.             self.targetMark = glow
  109.         end
  110.         self:RegisterEvent("PLAYER_TARGET_CHANGED", UpdateTargetMark)
  111.  
  112.         local cicon = self.Health:CreateTexture(nil, "OVERLAY")
  113.         cicon:SetPoint("LEFT", self, "TOPLEFT", 0, 2)
  114.         cicon:SetSize(15, 15)
  115.         cicon:SetAlpha(.75)
  116.         self.creatureIcon = cicon
  117.  
  118.         local threatIndicator = CreateFrame("Frame", nil, self)
  119.         self.ThreatIndicator = threatIndicator
  120.         self.ThreatIndicator.Override = UpdateThreatColor
  121.     end
  122. end
  123.  
  124. local classtex = {
  125.     rare = {"Interface\\MINIMAP\\ObjectIconsAtlas", .398, .463, .725, .79},
  126.     elite = {"Interface\\MINIMAP\\Minimap_skull_elite", 0, 1, 0, 1},
  127.     rareelite = {"Interface\\MINIMAP\\ObjectIconsAtlas", .398, .463, .926, .991},
  128.     worldboss = {"Interface\\MINIMAP\\ObjectIconsAtlas", .07, .13, .27, .33},
  129. }
  130.  
  131. lib.UpdateNPs = function(self, event, unit)
  132.     UpdateTargetMark(self, event, unit)
  133.  
  134.     local class = UnitClassification(unit)
  135.     if self.creatureIcon then
  136.         if class and classtex[class] then
  137.             local tex, a, b, c, d = unpack(classtex[class])
  138.             self.creatureIcon:SetTexture(tex)
  139.             self.creatureIcon:SetTexCoord(a, b, c, d)
  140.         else
  141.             self.creatureIcon:SetTexture(nil)
  142.         end
  143.     end
  144. end
  145.  
  146. oUF:RegisterStyle("Nameplates", lib.CreateNPs)
  147. oUF:SpawnNamePlates("oUF_NPs", lib.UpdateNPs)

Last edited by siweia : 06-06-17 at 04:08 AM.
  Reply With Quote