A Flamescale Wyrmkin
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:
local function UpdateColor(self, unit) local name = GetUnitName(unit, false) or UNKNOWN local status = UnitThreatSituation("player", unit) or false local r, g, b if not UnitIsConnected(unit) then r, g, b = .7, .7, .7 else if CustomUnits and CustomUnits[name] then r, g, b = 0, .8, .3 elseif UnitIsPlayer(unit) and UnitReaction(unit, "player") >= 5 then if NDuiDB["Nameplate"]["FriendlyCC"] then r, g, b = B.UnitColor(unit) else r, g, b = .3, .3, 1 end elseif UnitIsPlayer(unit) and UnitReaction(unit, "player") <= 4 and NDuiDB["Nameplate"]["HostileCC"] then r, g, b = B.UnitColor(unit) elseif UnitIsTapDenied(unit) and not UnitPlayerControlled(unit) then r, g, b = .6, .6, .6 else r, g, b = UnitSelectionColor(unit, true) if status and (NDuiDB["Nameplate"]["TankMode"] or DB.Role == "Tank") then if status == 3 then r, g, b = 1, 0, 1 elseif status == 2 or status == 1 then r, g, b = 1, .8, 0 end end end end if r or g or b then self:SetStatusBarColor(r, g, b) end if not NDuiDB["Nameplate"]["TankMode"] and DB.Role ~= "Tank" then if status and status == 3 then self.Shadow:SetBackdropBorderColor(1, 0, 0) elseif status and (status == 2 or status == 1) then self.Shadow:SetBackdropBorderColor(1, 1, 0) else self.Shadow:SetBackdropBorderColor(0, 0, 0) end else self.Shadow:SetBackdropBorderColor(0, 0, 0) end end local function UpdateThreatColor(self, event, unit) if(unit ~= self.unit) then return end local element = self.Health unit = unit or self.unit UpdateColor(element, unit) end local function UpdateTargetMark(self) local mark = self.targetMark if not mark then return end if UnitIsUnit(self.unit, "target") and not UnitIsUnit(self.unit, "player") then mark:Show() else mark:Hide() end end lib.CreateNPs = function(self, unit) self.mystyle = "nameplate" if unit:match("nameplate") then self:SetSize(NDuiDB["Nameplate"]["Width"] * 1.4, NDuiDB["Nameplate"]["Height"]) self:SetPoint("CENTER", 0, -3) local health = CreateFrame("StatusBar", nil, self) health:SetAllPoints() B.CreateSB(health) B.SmoothBar(health) self.Health = health self.Health.frequentUpdates = true self.Health.UpdateColor = UpdateColor lib.gen_hpstrings(self) lib.gen_castbar(self) lib.gen_RaidMark(self) lib.HealPrediction(self) lib.createAuras(self) self.power = B.CreateFS(self, 15, "", false, "LEFT", 0, 0) self.power:SetPoint("LEFT", self, "RIGHT", 2, 0) self:Tag(self.power, "[nppp]") if NDuiDB["Nameplate"]["Arrow"] then local arrow = self:CreateTexture(nil, "OVERLAY") arrow:SetSize(50, 50) arrow:SetTexture(DB.arrowTex) arrow:SetPoint("BOTTOM", self, "TOP", 0, 14) arrow:Hide() self.targetMark = arrow else local glow = CreateFrame("Frame", nil, self) glow:SetPoint("TOPLEFT", -5, 5) glow:SetPoint("BOTTOMRIGHT", 5, -5) glow:SetBackdrop({edgeFile = DB.glowTex, edgeSize = 4}) glow:SetBackdropBorderColor(1, 1, 1) glow:SetFrameLevel(0) glow:Hide() self.targetMark = glow end self:RegisterEvent("PLAYER_TARGET_CHANGED", UpdateTargetMark) local cicon = self.Health:CreateTexture(nil, "OVERLAY") cicon:SetPoint("LEFT", self, "TOPLEFT", 0, 2) cicon:SetSize(15, 15) cicon:SetAlpha(.75) self.creatureIcon = cicon local threatIndicator = CreateFrame("Frame", nil, self) self.ThreatIndicator = threatIndicator self.ThreatIndicator.Override = UpdateThreatColor end end local classtex = { rare = {"Interface\\MINIMAP\\ObjectIconsAtlas", .398, .463, .725, .79}, elite = {"Interface\\MINIMAP\\Minimap_skull_elite", 0, 1, 0, 1}, rareelite = {"Interface\\MINIMAP\\ObjectIconsAtlas", .398, .463, .926, .991}, worldboss = {"Interface\\MINIMAP\\ObjectIconsAtlas", .07, .13, .27, .33}, } lib.UpdateNPs = function(self, event, unit) UpdateTargetMark(self, event, unit) local class = UnitClassification(unit) if self.creatureIcon then if class and classtex[class] then local tex, a, b, c, d = unpack(classtex[class]) self.creatureIcon:SetTexture(tex) self.creatureIcon:SetTexCoord(a, b, c, d) else self.creatureIcon:SetTexture(nil) end end end oUF:RegisterStyle("Nameplates", lib.CreateNPs) oUF:SpawnNamePlates("oUF_NPs", lib.UpdateNPs)
Last edited by siweia : 06-06-17 at 04:08 AM.
|