Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UI, C = select(2, ...):unpack()
- local np = UI:NewModule("np")
- local minIconSize = 16
- local maxIconSize = 80
- local minTextSize = 6
- local maxTextSize = 20
- local defaultBuffShow = 3
- local defaultDebuffShow = 2
- local saveNameToGUID = true
- local watchUnitIDAuras = true
- local abovePlayers = true
- local aboveNPC = true
- local aboveFriendly = true
- local aboveNeutral = true
- local aboveHostile = true
- local barAnchorPoint = "BOTTOM"
- local plateAnchorPoint = "TOP"
- local Spacing = 0
- local barOffsetX = 0
- local barOffsetY = 8
- local iconsPerBar = 6
- local barGrowth = 1
- local numBars = 2
- local iconSize = 24
- local biggerSelfSpells = true
- local showCooldown = true
- local shrinkBar = true
- local cooldownSize = 10
- local stackSize = 10
- local showCooldownTexture = true
- local blinkTimeleft = 0.2 --20%
- local showTotems = true
- local scanDelay = 1
- local updateDelay = 1
- np.nameplates = {}
- np.GUIDs = {}
- np.names = {}
- np.onShowHooks = {}
- np.onHideHooks = {}
- np.plateGUIDs = {}
- np.isOnScreen = {}
- np.isOnUpdating = {}
- local function IsNamePlateFrame(frame)
- if frame:GetName() then return false end
- if frame:GetID() ~= 0 then return false end
- if frame:GetObjectType() ~= "Frame" then return false end
- if frame:GetNumChildren() == 0 then
- return false
- end
- if frame:GetNumRegions() == 0 then
- return false
- end
- return true
- end
- local function ScanWorldFrameChildren(n, ...)
- for i = 1, n do
- local frame = select(i, ...)
- if frame:IsShown() and IsNamePlateFrame(frame) then
- if not np.nameplates[frame] then
- np:NameplateFirstLoad(frame)
- np:SetupNameplate(frame)
- end
- end
- end
- end
- local lastChildren = 0
- local function FindNameplates()
- local curChildren = WorldFrame:GetNumChildren()
- if curChildren ~= lastChildren then
- lastChildren = curChildren
- ScanWorldFrameChildren(curChildren, WorldFrame:GetChildren())
- end
- end
- local function HideMouseoverRegion(frame)
- local region = select(6 ,frame:GetRegions())
- if region and region.Hide then
- region:Hide()
- end
- end
- local function RecycleNameplate(frame)
- np:RecycleNameplate(frame)
- if np.plateGUIDs[frame] then
- np.GUIDs[np.plateGUIDs[frame]] = false
- end
- local plateName = np:GetName(frame)
- if plateName and np.names[plateName] then
- np.names[plateName] = false
- end
- np.plateGUIDs[frame] = false
- end
- local function FoundPlateGUID(frame, GUID, unitID)
- np.plateGUIDs[frame] = GUID
- np.GUIDs[GUID] = frame
- np:FoundGUID(frame, GUID, unitID)
- end
- local function GetMouseoverGUID(frame)
- local unitID = "mouseover"
- if UnitExists(unitID) then
- FoundPlateGUID(frame, UnitGUID(unitID), unitID)
- end
- end
- local function FindPlateWithRaidIcon(iconNum)
- for frame in pairs(np.nameplates) do
- if np:IsMarked(frame) and np:GetRaidIcon(frame) == iconNum then
- return frame
- end
- end
- return nil
- end
- local function CheckRaidIconOnUnit(unitID, frame, raidNum, from)
- local targetID = unitID.."target"
- local targetIndex
- if UnitExists(targetID) and not UnitIsUnit("target", targetID) then
- targetIndex = GetRaidTargetIndex(targetID)
- if targetIndex and targetIndex == raidNum then
- FoundPlateGUID(frame, UnitGUID(targetID), targetID)
- return true
- end
- end
- return false
- end
- local function FindGUIDByRaidIcon(frame, raidNum, from)
- local group, num = "", 0
- if GetNumRaidMembers() > 1 then
- group, num = "raid", GetNumRaidMembers()
- elseif GetNumPartyMembers() > 0 then
- group, num = "party", GetNumPartyMembers()
- else
- return
- end
- local unitID
- for i = 1, num do
- unitID = group..i;
- if CheckRaidIconOnUnit(unitID, frame, raidNum, from) then
- return
- end
- if UnitExists(unitID.."pet") then
- if CheckRaidIconOnUnit(unitID.."pet", frame, raidNum, from) then
- return
- end
- end
- end
- end
- local function UpdateNameplateInfo(frame)
- if np:IsMouseover(frame) and not UnitExists("mouseover") then
- HideMouseoverRegion(frame)
- end
- if not np.plateGUIDs[frame] then
- if np:IsMouseover(frame) then
- GetMouseoverGUID(frame)
- elseif np:IsMarked(frame) then
- local raidNum = np:GetRaidIcon(frame)
- if raidNum and raidNum > 0 then
- FindGUIDByRaidIcon(frame, raidNum, "UpdateNameplateInfo")
- end
- end
- end
- frame.lnpLastUpdate = 0
- end
- local function CheckUnitIDForMatchingHP(unitID, frameName, current, max)
- local targetID = unitID.."target"
- if UnitName(targetID) == frameName then
- local health = UnitHealth(targetID)
- local maxHealth = UnitHealthMax(targetID)
- if health == current and maxHealth == max then
- return true
- end
- end
- return false
- end
- function np:NewNameplateCheckHP(frame)
- local bar = select(1, frame:GetChildren())
- if bar and bar.GetValue then
- local _, max = bar:GetMinMaxValues()
- local current = bar:GetValue()
- np.prevHealth[frame] = current
- if current > 0 and current ~= max then
- local group, num = "", 0
- if GetNumRaidMembers() > 1 then
- group, num = "raid", GetNumRaidMembers()
- elseif GetNumPartyMembers() > 0 then
- group, num = "party", GetNumPartyMembers()
- else
- return
- end
- local possibleUnits = {}
- local frameName = self:GetName(frame)
- local unitID, targetID, targetIndex
- for i = 1, num do
- unitID = group..i;
- if CheckUnitIDForMatchingHP(unitID, frameName, current, max) then
- table.insert(possibleUnits, #possibleUnits+1, unitID.."target")
- end
- if UnitExists(unitID.."pet") then
- if CheckUnitIDForMatchingHP(unitID.."pet", frameName, current, max) then
- table.insert(possibleUnits, #possibleUnits+1, unitID.."pettarget")
- end
- end
- end
- if #possibleUnits == 1 then
- FoundPlateGUID(frame, UnitGUID(possibleUnits[1]), possibleUnits[1])
- return true
- end
- end
- end
- end
- np.prevHealth = np.prevHealth or {}
- function np.OnNameplateShow(frame, ...)
- np:SetupNameplate(frame)
- np:NewNameplateCheckHP(frame)
- end
- local function ourOnShow(...) return np.OnNameplateShow(...) end
- function np.OnNameplateHide(frame, ...)
- np.isOnScreen[frame] = false
- np.isOnUpdating[frame] = false
- RecycleNameplate(frame)
- end
- local function ourOnHide(...) return np.OnNameplateHide(...) end
- function np.OnNameplateUpdate(frame, elapsed, ...)
- np.isOnUpdating[frame] = true
- if frame.lnpCheckForTarget then
- frame.lnpCheckForTarget = false
- if not np.plateGUIDs[frame] and frame:IsShown() and ((frame:GetAlpha() == 1) and UnitExists("target")) then
- FoundPlateGUID(frame, UnitGUID("target"), "target")
- end
- end
- frame.lnpLastUpdate = (frame.lnpLastUpdate or 0) + elapsed
- if frame.lnpLastUpdate > updateDelay then
- UpdateNameplateInfo(frame)
- end
- end
- local testing = false
- function np:HookNameplate(frame)
- if frame:HasScript("OnHide") and not self.onHideHooks[frame] then
- self.onHideHooks[frame] = true
- frame:HookScript("OnHide", ourOnHide)
- end
- if frame:HasScript("OnShow") and not self.onShowHooks[frame] then
- self.onShowHooks[frame] = true
- frame:HookScript("OnShow", ourOnShow)
- end
- end
- function np:NameplateFirstLoad(frame)
- self:HookNameplate(frame)
- end
- function np:SetupNameplate(frame)
- self.isOnScreen[frame] = true
- local plateName = self:GetName(frame)
- self.nameplates[frame] = plateName
- self.names[plateName] = frame
- np:NewNameplate(frame)
- frame.lnpCheckForTarget = true
- UpdateNameplateInfo(frame)
- end
- local function CheckForTargetGUID()
- local unitID = "target"
- local GUID
- for frame in pairs(np.nameplates) do
- if np:IsTarget(frame) then
- np.targeted = frame
- if not np.plateGUIDs[frame] then
- FoundPlateGUID(frame, UnitGUID(unitID), unitID)
- end
- np:TargetNameplate(frame)
- return
- end
- end
- end
- local function OnUpdate(frame, elapsed)
- if frame.checkTarget then
- frame.checkTarget = false
- CheckForTargetGUID()
- end
- FindNameplates()
- frame.lastUpdate = frame.lastUpdate + elapsed
- if frame.lastUpdate >= scanDelay then
- frame.lastUpdate = 0
- for frame, value in pairs(np.isOnScreen) do
- if (value == true and not frame:IsShown()) then
- np.onHideHooks[frame] = false
- np.isOnScreen[frame] = false
- np:HookNameplate(frame)
- np.OnNameplateHide(frame)
- elseif (value == false and frame:IsShown()) then
- np.onShowHooks[frame] = false
- np.isOnScreen[frame] = false
- np:HookNameplate(frame)
- np:SetupNameplate(frame, true)
- end
- end
- end
- end
- local function OnEvent(frame, event, ...)
- if event == "UPDATE_MOUSEOVER_UNIT" then
- if GetMouseFocus():GetName() == "WorldFrame" then
- local i = 0
- local mouseoverPlate
- for frame in pairs(np.nameplates) do
- if frame:IsShown() and np:IsMouseover(frame) then
- i = i + 1
- mouseoverPlate = frame
- end
- end
- if i == 1 then
- if not np.plateGUIDs[mouseoverPlate] then
- GetMouseoverGUID(mouseoverPlate)
- end
- np:MouseoverNameplate(mouseoverPlate)
- end
- end
- elseif event == "PLAYER_TARGET_CHANGED" then
- if UnitExists("target") then
- frame.checkTarget = true
- else
- np.targeted = nil
- end
- elseif event == "UNIT_TARGET" then
- local unitID = ...
- local targetID = unitID.."target"
- if UnitExists(targetID) and not UnitIsUnit("player", unitID) and UnitInRange(unitID) then
- local targetGUID = UnitGUID(targetID)
- local iconNum = GetRaidTargetIndex(targetID)
- if iconNum and iconNum > 0 then
- local foundPlate = FindPlateWithRaidIcon(iconNum)
- if foundPlate and not np.plateGUIDs[foundPlate] then
- FoundPlateGUID(foundPlate, targetGUID, targetID)
- end
- end
- if np.GUIDs[targetGUID] and np.GUIDs[targetGUID]:IsShown() then
- return
- end
- local health = UnitHealth(targetID)
- local maxHealth = UnitHealthMax(targetID)
- if health > 0 and health ~= maxHealth then
- local foundPlate = np:GetNameplateByUnit(targetID)
- if foundPlate and not np.plateGUIDs[foundPlate] then
- local name = UnitName(targetID)
- if name == np:GetName(foundPlate) then
- FoundPlateGUID(foundPlate, targetGUID, targetID)
- end
- end
- end
- end
- elseif event == "RAID_TARGET_UPDATE" then
- for frame in pairs(np.nameplates) do
- if frame:IsShown() and not np.plateGUIDs[frame] and np:IsMarked(frame) then
- local raidNum = np:GetRaidIcon(frame)
- if raidNum and raidNum > 0 then
- FindGUIDByRaidIcon(frame, raidNum, event)
- end
- end
- end
- end
- end
- np.frame = np.frame or CreateFrame("Frame")
- np.frame.lastUpdate = 0
- np.frame.lastHPCheck = 0
- np.frame.checkTarget = false
- np.frame:SetScript("OnUpdate", OnUpdate)
- np.frame:SetScript("OnEvent", OnEvent)
- np.frame:RegisterEvent('UPDATE_MOUSEOVER_UNIT')
- np.frame:RegisterEvent('PLAYER_TARGET_CHANGED')
- np.frame:RegisterEvent('UNIT_TARGET')
- np.frame:RegisterEvent('RAID_TARGET_UPDATE')
- np.frame:RegisterEvent('PLAYER_ENTERING_WORLD')
- local raidIconTexCoord = {
- [0] = {
- [0] = 1, --star
- [0.25] = 5, --moon
- },
- [0.25] = {
- [0] = 2, --circle
- [0.25] = 6, --square
- },
- [0.5] = {
- [0] = 3, --star
- [0.25] = 7, --cross
- },
- [0.75] = {
- [0] = 4, --star
- [0.25] = 8, --skull
- },
- }
- local function reactionByColor(red, green, blue, a)
- if red < .01 and blue < .01 and green > .99 then return "FRIENDLY", "NPC"
- elseif red < .01 and blue > .99 and green < .01 then return "FRIENDLY", "PLAYER"
- elseif red > .99 and blue < .01 and green > .99 then return "NEUTRAL", "NPC"
- elseif red > .99 and blue < .01 and green < .01 then return "HOSTILE", "NPC"
- else return "HOSTILE", "PLAYER" end
- end
- local colorToClass = {}
- local function pctToInt(number) return math.floor((100*number) + 0.5) end
- for classname, color in pairs(RAID_CLASS_COLORS) do
- colorToClass["C"..pctToInt(color.r)+pctToInt(color.g)+pctToInt(color.b)] = classname
- end
- local function threatByColor( region )
- if not region:IsShown() then return "LOW" end
- local redCan, greenCan, blueCan, alphaCan = region:GetVertexColor()
- if greenCan > .7 then return "MEDIUM" end
- if redCan > .7 then return "HIGH" end
- end
- local function combatByColor(r, g, b, a)
- return (r > .5 and g < .5)
- end
- local function GetHealthBarColor(frame)
- local bar = select(1, frame:GetChildren())
- if bar and bar.GetStatusBarColor then
- return bar:GetStatusBarColor()
- end
- return nil
- end
- local function RemoveHexColor(inputString)
- local find = inputString:find("|c")
- if find then
- inputString = inputString:sub(find+10)
- end
- inputString = inputString:gsub("|r", "")
- return inputString
- end
- function np:GetName(frame)
- local nameRegion = select(7, frame:GetRegions())
- if nameRegion and nameRegion.GetText then
- return RemoveHexColor( nameRegion:GetText() )
- end
- return nil
- end
- function np:GetScale(frame)
- return frame:GetScale()
- end
- function np:GetVisibleFrame(frame)
- return frame
- end
- function np:GetReaction(frame)
- local r,g,b = GetHealthBarColor(frame)
- if r then
- return reactionByColor(r, g, b )
- end
- return nil
- end
- function np:GetType(frame)
- local r, g, b = GetHealthBarColor(frame)
- if r then
- return select(2, reactionByColor( r, g, b ) )
- end
- return nil
- end
- function np:IsTarget(frame)
- return frame:IsShown() and frame:GetAlpha() == 1 and UnitExists("target") or false
- end
- function np:GetRaidIcon(frame)
- local region = select(10 ,frame:GetRegions())
- if region and region.IsShown and region:IsShown() and region.GetTexCoord then
- local ULx,ULy = region:GetTexCoord() --,LLx,LLy,URx,URy,LRx,LRy
- if ULx and ULy then
- return raidIconTexCoord[ULx] and raidIconTexCoord[ULx][ULy] or 0
- end
- end
- return nil
- end
- function np:IsMouseover(frame)
- local region = select(6 ,frame:GetRegions())
- if region and region.IsShown then
- return region:IsShown() and true or false
- end
- return nil
- end
- function np:IsMarked(frame)
- local region = select(10 ,frame:GetRegions())
- if region and region.IsShown then
- return region:IsShown() and true or false
- end
- return nil
- end
- function np:GetGUID(frame)
- return self.plateGUIDs[frame]
- end
- function np:GetTargetNameplate()
- if self.targeted and self.targeted:IsShown() then
- return self.targeted
- end
- end
- function np:GetNameplateByGUID(GUID)
- if self.GUIDs[GUID] and self.GUIDs[GUID]:IsShown() then
- return self.GUIDs[GUID]
- end
- end
- function np:GetNameplateByName(name)
- if self.names[name] and self.names[name]:IsShown() then
- return self.names[name]
- end
- end
- function np:GetNameplateByUnit(unitID)
- if unitID=="player" then return end
- for frame in pairs(np.nameplates) do
- if frame:IsShown() then
- local name = UI:utf8sub(select(7, frame:GetRegions()):GetText(), 13, false)
- local cur = frame.healthBar:GetValue()
- local max = select(2, frame.healthBar:GetMinMaxValues())
- if UnitHealth(unitID)>1 and name and name==UnitName(unitID) and cur==UnitHealth(unitID) and max==UnitHealthMax(unitID) then
- return frame
- end
- end
- end
- end
- local function Round(num, zeros)
- return math.floor( num * 10 ^ (zeros or 0) + 0.5 ) / 10 ^ (zeros or 0)
- end
- local function GetFullName(unitID)
- local name = GetUnitName(unitID, true)
- name = name:gsub(" - ","")
- return name
- end
- local totemList = {
- 2484,--Earthbind Totem
- 8143,--Tremor Totem
- 8177,--Grounding Totem
- 8512,--Windfury Totem
- 6495,--Sentry Totem
- 8170,--Cleansing Totem
- 3738,--Wrath of Air Totem
- 2062,--Earth Elemental Totem
- 2894,--Fire Elemental Totem
- 58734,--Magma Totem
- 58582,--Stoneclaw Totem
- 58753,--Stoneskin Totem
- 58739,--Fire Resistance Totem
- 58656,--Flametongue Totem
- 58745,--Frost Resistance Totem
- 58757,--Healing Stream Totem
- 58774,--Mana Spring Totem
- 58749,--Nature Resistance Totem
- 58704,--Searing Totem
- 58643,--Strength of Earth Totem
- 57722,--Totem of Wrath
- }
- local defaultSpells1 = {
- 118, --Polymorph
- 51514, --Hex
- 710, --Banish
- 6358, --Seduction
- 6770, --Sap
- 605, --Mind Control
- 33786, --Cyclone
- 5782, --Fear
- 5484, --Howl of Terror
- 6789, --Death Coil
- 45438, --Ice Block
- 642, --Divine Shield
- 8122, --Psychic Scream
- 339, --Entangling Roots
- 23335, -- Silverwing Flag (alliance WSG flag)
- 23333, -- Warsong Flag (horde WSG flag)
- 34976, -- Netherstorm Flag (EotS flag)
- 2094, --Blind
- 33206, --Pain Suppression (priest)
- 29166, --Innervate (druid)
- 47585, --Dispersion (priest)
- 19386, --Wyvern Sting (hunter)
- }
- local defaultSpells2 = {
- 15487, --Silence (priest)
- 10060, --Power Infusion (priest)
- 2825, --Bloodlust
- 5246, --Intimidating Shout (warrior)
- 31224, --Cloak of Shadows (rogue)
- 498, --Divine Protection
- 47476, --Strangulate (warlock)
- 31884, --Avenging Wrath (pally)
- 37587, --Bestial Wrath (hunter)
- 12472, --Icy Veins (mage)
- 49039, --Lichborne (DK)
- 48792, --Icebound Fortitude (DK)
- 5277, --Evasion (rogue)
- 53563, --Beacon of Light (pally)
- 22812, --Barkskin (druid)
- 67867, --Trampled (ToC arena spell when you run over someone)
- 1499, --Freezing Trap
- 2637, --Hibernate
- 64044, --Psychic Horror
- 19503, --Scatter Shot (hunter)
- 34490, --Silencing Shot (hunter)
- 10278, --Hand of Protection (pally)
- 10326, --Turn Evil (pally)
- 44572, --Deep Freeze (mage)
- 20066, --Repentance (pally)
- 46968, --Shockwave (warrior)
- 46924, --Bladestorm (warrior)
- 16689, --Nature's Grasp (Druid)
- 53601, --Π±Π»ΡΠ΄ΠΎΡΠΈΡ ΠΏΠ΅Π»Π°Π΄ΠΈΠ½Π°
- }
- local myClass = select(2, UnitClass("player"))
- if myClass == "DRUID" or myClass == "ROGUE" then
- table.insert(defaultSpells2, #defaultSpells2+1, 132)
- table.insert(defaultSpells2, #defaultSpells2+1, 16882)
- table.insert(defaultSpells2, #defaultSpells2+1, 6512)
- end
- local regEvents = {
- "PLAYER_TARGET_CHANGED",
- "UPDATE_MOUSEOVER_UNIT",
- "UNIT_AURA",
- "UNIT_TARGET",
- }
- local spellOpts = {}
- local ignoreDefaultSpell = {}
- local buffFrames = {}
- local guidBuffs = {}
- local nametoGUIDs = {}
- local buffBars = {}
- local totems = {}
- local name, texture
- for i=1,table.getn(totemList) do
- name, _, texture = GetSpellInfo(totemList[i])
- totems[name] = texture
- end
- local spellName
- for i=1, table.getn(defaultSpells1) do
- spellName = GetSpellInfo(defaultSpells1[i])
- if spellName then
- spellOpts[spellName] = {
- iconSize = 80, --max size
- cooldownSize = 18,--almost max.
- show = 1, --always show spell
- stackSize = 18,
- }
- end
- end
- for i=1, table.getn(defaultSpells2) do
- spellName = GetSpellInfo(defaultSpells2[i])
- if spellName then
- spellOpts[spellName] = {
- iconSize = 40, --mid size
- cooldownSize = 14,
- show = 1, --always show spell
- stackSize = 14,
- }
- end
- end
- local function HidePlateSpells(plate)
- if buffFrames[plate] then
- for i=1, table.getn(buffFrames[plate]) do
- buffFrames[plate][i]:Hide()
- end
- end
- end
- local function isTotem(name)
- return totems[name]
- end
- local function ShouldAddBuffs(plate)
- local plateName = np:GetName(plate) or "UNKNOWN"
- if showTotems == false and isTotem(plateName) then
- return false
- end
- local plateType = np:GetType(plate)
- if (abovePlayers == true and plateType == "PLAYER") or (aboveNPC == true and plateType == "NPC") then
- local plateReaction = np:GetReaction(plate)
- if aboveFriendly == true and plateReaction == "FRIENDLY" then
- return true
- elseif aboveNeutral == true and plateReaction == "NEUTRAL" then
- return true
- elseif aboveHostile == true and plateReaction == "HOSTILE" then
- return true
- end
- end
- return false
- end
- local function RemoveOldSpells(GUID)
- for i=(numBars * iconsPerBar), 1, -1 do
- if guidBuffs[GUID] and guidBuffs[GUID][i] then
- if guidBuffs[GUID][i].expirationTime and guidBuffs[GUID][i].expirationTime > 0 and GetTime() > guidBuffs[GUID][i].expirationTime then
- table.remove(guidBuffs[GUID], i)
- end
- end
- end
- end
- local function CreateBarFrame(parentFrame, realPlate)
- local f = CreateFrame("frame", nil, parentFrame)
- f.realPlate = realPlate
- f:SetFrameStrata("BACKGROUND")
- f:SetFrameLevel(parentFrame:GetFrameLevel())
- f:SetWidth(1)
- f:SetHeight(1)
- f.barBG = f:CreateTexture(nil,"LOW")
- f.barBG:SetAllPoints(true)
- f.barBG:SetTexture(1,1,1,0.3)
- if showBarBackground == true then
- f.barBG:Show()
- else
- f.barBG:Hide()
- end
- f:Show()
- return f
- end
- local function BuildPlateBars(plate, visibleFrame)
- buffBars[plate] = buffBars[plate] or {}
- if not buffBars[plate][1] then
- buffBars[plate][1] = CreateBarFrame(visibleFrame, plate)
- end
- buffBars[plate][1]:ClearAllPoints()
- buffBars[plate][1]:SetPoint(barAnchorPoint, visibleFrame, plateAnchorPoint, barOffsetX, barOffsetY)
- buffBars[plate][1]:SetParent(visibleFrame)
- local barPoint = barAnchorPoint
- local parentPoint = plateAnchorPoint
- if barGrowth == 1 then
- barPoint = string.gsub(barPoint, "TOP", "BOTTOM");
- parentPoint = string.gsub(parentPoint, "BOTTOM", "TOP");
- else
- barPoint = string.gsub(barPoint, "BOTTOM,", "TOP");
- parentPoint = string.gsub(parentPoint, "TOP", "BOTTOM");
- end
- if numBars > 1 then
- for r=2, numBars do
- if not buffBars[plate][r] then
- buffBars[plate][r] = CreateBarFrame(visibleFrame, plate)
- end
- buffBars[plate][r]:ClearAllPoints()
- buffBars[plate][r]:SetPoint(barPoint, buffBars[plate][r-1], parentPoint, 0, 0)
- buffBars[plate][r]:SetParent(visibleFrame)
- end
- end
- end
- local function UpdateBuffCDSize(buffFrame, size)
- buffFrame.cd:SetFont("Fonts\\FRIZQT__.TTF", size, "NORMAL")
- buffFrame.cdbg:SetHeight(buffFrame.cd:GetStringHeight())
- end
- local function UpdateBuffSize(frame, size)
- frame.icon:SetWidth(size)
- frame.icon:SetHeight(size)
- frame:SetWidth(size)
- if showCooldown == true then
- frame:SetHeight(size + frame.cd:GetStringHeight())
- else
- frame:SetHeight(size)
- end
- end
- local function SetStackSize(buffFrame, size)
- buffFrame.stack:SetFont("Fonts\\FRIZQT__.TTF", size, "OUTLINE")
- end
- local function iconOnShow(self)
- self:SetAlpha(1)
- self.cdbg:Hide()
- self.cd:Hide()
- self.cdtexture:Hide()
- self.stack:Hide()
- if showCooldown == true and self.expirationTime > 0 then
- self.cdbg:Show()
- self.cd:Show()
- if showCooldownTexture == true then
- self.cdtexture:SetCooldown(self.startTime, self.duration);
- self.cdtexture:Show()
- end
- end
- local iconSize = iconSize
- local cooldownSize = cooldownSize
- local stackSize = stackSize
- local spellName = self.spellName or "X"
- local spellOpts = np:HaveSpellOpts(spellName)
- if spellOpts then
- iconSize = spellOpts.iconSize or iconSize
- cooldownSize = spellOpts.cooldownSize or cooldownSize
- stackSize = spellOpts.stackSize or stackSize
- end
- UpdateBuffCDSize(self, cooldownSize)
- if self.stackCount and self.stackCount > 1 then
- self.stack:SetText(self.stackCount)
- self.stack:Show()
- SetStackSize(self, stackSize)
- end
- if self.isDebuff then
- local colour = DebuffTypeColor[self.debuffType or ""]
- if colour then
- self.icon:SetBackdropBorderColor(colour.r, colour.g, colour.b)
- end
- end
- if self.playerCast and biggerSelfSpells == true then
- UpdateBuffSize(self, iconSize * 1.2)
- else
- UpdateBuffSize(self, iconSize)
- end
- end
- local function iconOnUpdate(self, elapsed)
- self.lastUpdate = self.lastUpdate + elapsed
- if self.lastUpdate > 0.1 then
- self.lastUpdate = 0
- if self.expirationTime > 0 then
- local rawTimeLeft = self.expirationTime - GetTime()
- local timeLeft
- if rawTimeLeft < 10 then
- timeLeft = Round(rawTimeLeft, 1)
- else
- timeLeft = Round(rawTimeLeft)
- end
- if showCooldown == true then
- self.cd:SetText(timeLeft)
- self.cdbg:SetWidth(self.cd:GetStringWidth())
- end
- if (timeLeft / self.duration ) < blinkTimeleft and timeLeft < 60 then
- local f = GetTime() % 1
- if f > 0.5 then
- f = 1 - f
- end
- self:SetAlpha(f * 3)
- end
- if GetTime() > self.expirationTime then
- self:Hide()
- local GUID = np:GetGUID(self.realPlate)
- if GUID then
- RemoveOldSpells(GUID)
- np:AddBuffsToPlate(self.realPlate, GUID)
- else
- local plateName = np:GetName(self.realPlate)
- if plateName and nametoGUIDs[plateName] then
- RemoveOldSpells(nametoGUIDs[plateName])
- np:AddBuffsToPlate(self.realPlate, nametoGUIDs[plateName])
- end
- end
- end
- end
- end
- end
- function np:AddBuffsToPlate(plate, GUID)
- if not buffFrames[plate] or not buffFrames[plate][numBars] then
- np:BuildBuffFrame(plate)
- end
- local t, f
- if guidBuffs[GUID] then
- table.sort(guidBuffs[GUID], function(a,b)
- if(a and b) then
- if a.playerCast ~= b.playerCast then
- return (a.playerCast or 0) > (b.playerCast or 0)
- elseif a.expirationTime == b.expirationTime then
- return a.name < b.name
- else
- return (a.expirationTime or 0) < (b.expirationTime or 0)
- end
- end
- end)
- for i=1, numBars * iconsPerBar do
- if buffFrames[plate][i] then
- if guidBuffs[GUID][i] then
- buffFrames[plate][i].spellName = guidBuffs[GUID][i].name or ""
- buffFrames[plate][i].expirationTime = guidBuffs[GUID][i].expirationTime or 0
- buffFrames[plate][i].duration = guidBuffs[GUID][i].duration or 1
- buffFrames[plate][i].startTime = guidBuffs[GUID][i].startTime or GetTime()
- buffFrames[plate][i].stackCount = guidBuffs[GUID][i].stackCount or 0
- buffFrames[plate][i].isDebuff = guidBuffs[GUID][i].isDebuff
- buffFrames[plate][i].debuffType = guidBuffs[GUID][i].debuffType
- buffFrames[plate][i].playerCast = guidBuffs[GUID][i].playerCast
- buffFrames[plate][i].texture:SetTexture("Interface\\Icons\\"..guidBuffs[GUID][i].icon)
- buffFrames[plate][i]:Show()
- iconOnShow(buffFrames[plate][i])
- iconOnUpdate(buffFrames[plate][i], 1)
- else
- buffFrames[plate][i]:Hide()
- end
- end
- end
- UpdateAllBarSizes(plate)
- end
- end
- local function iconOnHide(self)
- self.stack:Hide()
- self.cdbg:Hide()
- self.cd:Hide()
- self.cdtexture:Hide()
- self:SetAlpha(1)
- UpdateBuffSize(self, iconSize)
- end
- local function CreateBuffFrame(parentFrame, realPlate)
- local f = CreateFrame("Frame", nil, parentFrame)
- f.realPlate = realPlate
- f:SetFrameStrata("LOW")
- f.icon = CreateFrame("Frame", nil, f)
- f.icon:SetPoint("TOP", f)
- f.texture = f.icon:CreateTexture(nil, "BORDER")
- f.texture:SetPoint("TOPLEFT", 2,-2)
- f.texture:SetPoint("BOTTOMRIGHT", -2,2)
- f.texture:SetTexCoord(.07,.93,.07,.93)
- local cd = f:CreateFontString(nil, "ARTWORK", "ChatFontNormal")
- cd:SetText("0")
- cd:SetPoint("TOP", f.icon, "BOTTOM")
- f.cd = cd
- f.cdbg = f:CreateTexture(nil,"BACKGROUND")
- f.cdbg:SetTexture(0,0,0,.75)
- f.cdbg:SetPoint("CENTER", cd)
- f.cdtexture = CreateFrame("Cooldown", nil, f.icon, "CooldownFrameTemplate")
- f.cdtexture:SetReverse(true)
- f.cdtexture:SetDrawEdge(false)
- f.cdtexture:SetAllPoints(true)
- f.stack = f.icon:CreateFontString(nil, "OVERLAY", "ChatFontNormal")
- f.stack:SetText("0")
- f.stack:SetPoint("BOTTOMRIGHT", f.icon, "BOTTOMRIGHT", -1, 3)
- f.lastUpdate = 0
- f.expirationTime = 0
- f:SetScript("OnShow", iconOnShow)
- f:SetScript("OnHide", iconOnHide)
- f:SetScript("OnUpdate", iconOnUpdate)
- f.stackCount = 0
- f.cdbg:Hide()
- f.cd:Hide()
- f.cdtexture:Hide()
- f.stack:Hide()
- return f
- end
- function np:BuildBuffFrame(plate, reset, onlyOne)
- local visibleFrame = plate
- if not buffBars[plate] then
- BuildPlateBars(plate, visibleFrame)
- end
- if not buffBars[plate][numBars] then
- BuildPlateBars(plate, visibleFrame)
- end
- buffFrames[plate] = buffFrames[plate] or {}
- if reset then
- for i=1, table.getn(buffFrames[plate]) do
- buffFrames[plate][i]:Hide()
- end
- end
- local total = 1
- if not buffFrames[plate][total] then
- buffFrames[plate][total] = CreateBuffFrame(buffBars[plate][1], plate)
- end
- buffFrames[plate][total]:SetParent(buffBars[plate][1])
- buffFrames[plate][total]:ClearAllPoints()
- buffFrames[plate][total]:SetPoint("BOTTOMLEFT", buffBars[plate][1])
- if onlyOne then
- return
- end
- local prevFrame = buffFrames[plate][total]
- for i=2, iconsPerBar do
- total = total + 1
- if not buffFrames[plate][total] then
- buffFrames[plate][total] = CreateBuffFrame(buffBars[plate][1], plate)
- end
- buffFrames[plate][total]:SetParent(buffBars[plate][1])
- buffFrames[plate][total]:ClearAllPoints()
- buffFrames[plate][total]:SetPoint("BOTTOMLEFT", prevFrame, "BOTTOMRIGHT", Spacing, 0)
- prevFrame = buffFrames[plate][total]
- end
- if numBars > 1 then
- for r=2, numBars do
- for i=1, iconsPerBar do
- total = total + 1
- if not buffFrames[plate][total] then
- buffFrames[plate][total] = CreateBuffFrame(buffBars[plate][r], plate)
- end
- buffFrames[plate][total]:SetParent(buffBars[plate][r])
- buffFrames[plate][total]:ClearAllPoints()
- if i == 1 then
- buffFrames[plate][total]:SetPoint("BOTTOMLEFT", buffBars[plate][r])
- else
- buffFrames[plate][total]:SetPoint("BOTTOMLEFT", prevFrame, "BOTTOMRIGHT")
- end
- prevFrame = buffFrames[plate][total]
- end
- end
- end
- end
- local function GetBarChildrenSize(n, ...)
- local frame
- local totalWidth = 1
- local totalHeight = 1
- if n > iconsPerBar then
- n = iconsPerBar
- end
- for i = 1, n do
- frame = select(i, ...)
- if shrinkBar == true then
- if frame:IsShown() then
- totalWidth = totalWidth + frame:GetWidth()
- if frame:GetHeight() > totalHeight then
- totalHeight = frame:GetHeight()
- end
- end
- else
- totalWidth = totalWidth + frame:GetWidth()
- if frame:GetHeight() > totalHeight then
- totalHeight = frame:GetHeight()
- end
- end
- end
- return totalWidth, totalHeight
- end
- local function UpdateBarSize(barFrame)
- if barFrame:GetNumChildren() == 0 then
- return
- end
- local totalWidth, totalHeight = GetBarChildrenSize(barFrame:GetNumChildren(), barFrame:GetChildren())
- barFrame:SetWidth(totalWidth)
- barFrame:SetHeight(totalHeight)
- end
- function UpdateAllBarSizes(plate)
- for r=1, numBars do
- UpdateBarSize(buffBars[plate][r])
- end
- end
- local function AddOurStuffToPlate(plate)
- local GUID = np:GetGUID(plate)
- if GUID then
- RemoveOldSpells(GUID)
- np:AddBuffsToPlate(plate, GUID)
- return
- end
- local plateName = np:GetName(plate) or "UNKNOWN"
- if saveNameToGUID == true and nametoGUIDs[plateName] and (np:GetType(plate) == "PLAYER") then
- RemoveOldSpells(nametoGUIDs[plateName])
- np:AddBuffsToPlate(plate, nametoGUIDs[plateName])
- end
- end
- function np:HaveSpellOpts(spellName)
- if not ignoreDefaultSpell[spellName] and spellOpts[spellName] then
- return spellOpts[spellName]
- end
- return false
- end
- function np:CollectUnitInfo(unitID)
- local GUID = UnitGUID(unitID)
- local name = UnitName(unitID)
- if saveNameToGUID == true and UnitIsPlayer(unitID) or UnitClassification(unitID) == "worldboss" then
- nametoGUIDs[name] = GUID
- end
- if watchUnitIDAuras == true then
- guidBuffs[GUID] = guidBuffs[GUID] or {}
- for i=table.getn(guidBuffs[GUID]), 1, -1 do
- table.remove(guidBuffs[GUID], i)
- end
- local i = 1;
- local name, rank, icon, count, dispelType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId
- while UnitBuff(unitID, i) do
- name, rank, icon, count, dispelType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitBuff(unitID, i)
- for _, _, shortIcon in icon:gmatch("(.+)\\(.+)\\(.+)") do
- icon = shortIcon
- break
- end
- local spellOpts = self:HaveSpellOpts(name)
- if spellOpts and spellOpts.show then
- if spellOpts.show == 1 or (spellOpts.show == 2 and unitCaster and unitCaster == "player") then
- table.insert(guidBuffs[GUID], {
- name = name,
- icon = icon,
- expirationTime = expirationTime,
- startTime = expirationTime - duration,
- duration = duration,
- playerCast = unitCaster and unitCaster == "player" and 1,
- stackCount = count,
- sID = spellId,
- caster = unitCaster and GetFullName(unitCaster),
- })
- end
- else
- if defaultBuffShow == 1 or (defaultBuffShow == 2 and unitCaster and unitCaster == "player") then
- table.insert(guidBuffs[GUID], {
- name = name,
- icon = icon,
- expirationTime = expirationTime,
- startTime = expirationTime - duration,
- duration = duration,
- playerCast = unitCaster and unitCaster == "player" and 1,
- stackCount = count,
- sID = spellId,
- caster = unitCaster and GetFullName(unitCaster),
- })
- end
- end
- i=i + 1
- end
- i = 1;
- local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId
- while UnitDebuff(unitID, i) do
- name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebuff(unitID, i)
- for _, _, shortIcon in icon:gmatch("(.+)\\(.+)\\(.+)") do
- icon = shortIcon
- break
- end
- local spellOpts = self:HaveSpellOpts(name)
- if spellOpts and spellOpts.show then
- if spellOpts.show == 1 or (spellOpts.show == 2 and unitCaster and unitCaster == "player") then
- table.insert(guidBuffs[GUID], {
- name = name,
- icon = icon,
- expirationTime = expirationTime,
- startTime = expirationTime - duration,
- duration = duration,
- playerCast = unitCaster and unitCaster == "player" and 1,
- stackCount = count,
- debuffType = debuffType,
- isDebuff = true,
- sID = spellId,
- caster = unitCaster and GetFullName(unitCaster),
- })
- end
- else
- if defaultDebuffShow == 1 or (defaultDebuffShow == 2 and unitCaster and unitCaster == "player") then
- table.insert(guidBuffs[GUID], {
- name = name,
- icon = icon,
- expirationTime = expirationTime,
- startTime = expirationTime - duration,
- duration = duration,
- playerCast = unitCaster and unitCaster == "player" and 1,
- stackCount = count,
- debuffType = debuffType,
- isDebuff = true,
- sID = spellId,
- caster = unitCaster and GetFullName(unitCaster),
- })
- end
- end
- i=i + 1
- end
- end
- if not self:UpdatePlateByGUID(GUID) and (UnitIsPlayer(unitID) or UnitClassification(unitID) == "worldboss") then
- self:UpdatePlateByName(name)
- end
- end
- function np:PLAYER_TARGET_CHANGED()
- if UnitExists("target") then
- self:CollectUnitInfo("target")
- end
- end
- function np:UNIT_TARGET(unitID)
- if not UnitIsUnit(unitID, "player") and UnitExists(unitID.."target") then
- self:CollectUnitInfo(unitID.."target")
- end
- end
- function np:UPDATE_MOUSEOVER_UNIT()
- if UnitExists("mouseover") then
- self:CollectUnitInfo("mouseover")
- end
- end
- function np:UNIT_AURA(unitID)
- if unitID=="player" then return end
- if UnitExists(unitID) then
- self:CollectUnitInfo(unitID)
- end
- end
- function np:UpdatePlateByGUID(GUID)
- local plate = np:GetNameplateByGUID(GUID)
- if plate then
- if ShouldAddBuffs(plate) == true then
- np:AddBuffsToPlate(plate, GUID)
- return true
- end
- end
- return false
- end
- function np:UpdatePlateByName(name)
- local GUID = nametoGUIDs[name]
- if GUID then
- local plate = np:GetNameplateByName(name)
- if plate then
- if ShouldAddBuffs(plate) == true then
- np:AddBuffsToPlate(plate, GUID)
- end
- return true
- end
- end
- end
- local function PlateOnShow(frame)
- local name = frame.name
- name:SetText(UI:utf8sub(frame.nameOld:GetText(),15, true))
- frame.healthBar:ClearAllPoints()
- frame.healthBar:SetPoint("TOPLEFT", frame, 15, -15)
- frame.healthBar:SetPoint("BOTTOMRIGHT", frame, -15, 15)
- frame.highlight:ClearAllPoints()
- frame.highlight:SetAllPoints(frame.healthBar)
- frame.highlight:Hide()
- end
- local function PlateOnEvent(self, event, unit, spell, _, castid)
- if unit=="player" or unit==unit:match("raid%d") or unit==unit:match("raidpet%d") then return end
- local unitName = UI:utf8sub(select(7, self:GetRegions()):GetText(), 13, false)
- local curHP = self.healthBar:GetValue()
- local maxHP = select(2, self.healthBar:GetMinMaxValues())
- if unitName~=UnitName(unit) or curHP~=UnitHealth(unit) or maxHP~=UnitHealthMax(unit) then
- return
- end
- local castbar = self.Castbar
- if event=="UNIT_SPELLCAST_START" then
- local castbar = self.Castbar;
- local name, _, text, texture, startTime, endTime, isTradeSkill, castid, interrupt = UnitCastingInfo(unit)
- if(not name) then castbar:Hide(); return end
- castbar.duration = GetTime() - (startTime/1000);
- castbar.max = (endTime - startTime) / 1000;
- if(mergeTradeskill and isTradeSkill and UnitIsUnit(unit, "player")) then
- castbar.duration = castbar.duration + (castbar.max * tradeskillCurrent);
- castbar.max = castbar.max * tradeskillTotal;
- if(unit == "player") then
- tradeskillCurrent = tradeskillCurrent + 1;
- end
- castbar:SetValue(castbar.duration);
- else
- castbar:SetValue(0);
- end
- castbar:SetMinMaxValues(0, castbar.max);
- castbar:SetAlpha(1.0);
- castbar.holdTime = 0;
- castbar.casting = 1;
- castbar.castid = castid;
- castbar.delay = 0;
- castbar.channeling = nil;
- castbar.fadeOut = nil;
- castbar.interrupt = interrupt;
- castbar.isTradeSkill = isTradeSkill;
- if(castbar.Icon) then
- castbar.Icon:SetTexture(texture);
- end
- castbar:SetStatusBarColor(1,.8,0)
- castbar:Show();
- elseif event=="UNIT_SPELLCAST_FAILED" then
- local castbar = self.Castbar;
- if(castbar.castid ~= castid) then return; end
- castbar:SetValue(castbar.max);
- castbar.casting = nil;
- castbar.channeling = nil;
- castbar.interrupt = nil;
- castbar.fadeOut = 1;
- castbar.holdTime = GetTime() + CASTING_BAR_HOLD_TIME;
- castbar:SetStatusBarColor(1,.2,.2)
- elseif event=="UNIT_SPELLCAST_INTERRUPTED" then
- local castbar = self.Castbar;
- if(castbar.castid ~= castid) then
- return;
- end
- castbar:SetValue(castbar.max);
- castbar.casting = nil;
- castbar.channeling = nil;
- castbar.fadeOut = 1;
- castbar.holdTime = GetTime() + CASTING_BAR_HOLD_TIME;
- castbar:SetStatusBarColor(1,.2,.2)
- elseif event=="UNIT_SPELLCAST_DELAYED" then
- local castbar = self.Castbar;
- if(castbar:IsShown()) then
- local name, _, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(unit);
- if(not name) then return; end
- local duration = GetTime() - (startTime / 1000);
- if(duration < 0) then duration = 0; end
- castbar.delay = castbar.delay + castbar.duration - duration;
- castbar.duration = duration;
- castbar:SetValue(duration);
- if(not castbar.casting) then
- castbar.casting = 1;
- castbar.channeling = nil;
- castbar.fadeOut = 0;
- end
- end
- elseif event=="UNIT_SPELLCAST_STOP" then
- local castbar = self.Castbar;
- if(castbar.castid == castid and castbar.casting and (not castbar.fadeOut)) then
- if(mergeTradeskill and UnitIsUnit(unit, "player")) then
- if(tradeskillCurrent == tradeskillTotal) then
- mergeTradeskill = false;
- end
- else
- castbar:SetValue(castbar.max);
- castbar.casting = nil;
- castbar.interrupt = nil;
- castbar.fadeOut = 1;
- castbar.holdTime = 0;
- end
- end
- elseif event=="UNIT_SPELLCAST_CHANNEL_START" then
- local castbar = self.Castbar;
- local name, _, text, texture, startTime, endTime, isTradeSkill, notInterruptible = UnitChannelInfo(unit);
- if(not name) then return; end
- castbar.duration = ((endTime / 1000) - GetTime());
- castbar.max = (endTime - startTime) / 1000;
- castbar.delay = 0;
- castbar:SetMinMaxValues(0, castbar.max);
- castbar:SetValue(castbar.duration);
- if(castbar.Icon) then
- castbar.Icon:SetTexture(texture);
- end
- castbar:SetAlpha(1.0);
- castbar.holdTime = 0;
- castbar.casting = nil;
- castbar.channeling = 1;
- castbar.interrupt = notInterruptible;
- castbar.fadeOut = nil;
- castbar:SetStatusBarColor(.4,1,0)
- castbar:Show();
- elseif event=="UNIT_SPELLCAST_CHANNEL_UPDATE" then
- local castbar = self.Castbar;
- if(castbar:IsShown()) then
- local name, _, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(unit);
- if(not name) then return; end
- local duration = ((endTime / 1000) - GetTime());
- castbar.delay = castbar.delay + castbar.duration - duration;
- castbar.duration = duration;
- castbar.max = (endTime - startTime) / 1000;
- castbar:SetMinMaxValues(0, castbar.max);
- castbar:SetValue(duration);
- end
- elseif event=="UNIT_SPELLCAST_CHANNEL_STOP" then
- local castbar = self.Castbar;
- if(castbar:IsShown() or castbar.channeling) then
- castbar:SetValue(castbar.max);
- castbar.channeling = nil;
- castbar.interrupt = nil;
- castbar.fadeOut = 1;
- castbar.holdTime = 0;
- castbar:SetStatusBarColor(1,.2,.2)
- end
- end
- end
- local function PlateCastbarOnUpdate(self, elapsed)
- if not self then return end
- if(self.casting) then
- local duration = self.duration + elapsed;
- if(duration >= self.max) then
- self:SetValue(self.max)
- self.holdTime = 0
- self.fadeOut = 1
- self.casting = nil
- return
- end
- self.duration = duration
- self:SetValue(duration)
- elseif(self.channeling) then
- local duration = self.duration - elapsed;
- if(duration <= 0) then
- self.fadeOut = 1
- self.channeling = nil
- self.holdTime = 0
- return
- end
- self.duration = duration
- self:SetValue(duration)
- elseif(GetTime() < self.holdTime) then
- return
- elseif(self.fadeOut) then
- local alpha = self:GetAlpha() - CASTING_BAR_ALPHA_STEP;
- if (alpha > 0.05) then
- self:SetAlpha(alpha);
- else
- self.fadeOut = nil;
- self:Hide();
- end
- end
- end
- local function StylePlates(frame)
- if frame.done then return end
- frame.healthBar, frame.castBar = frame:GetChildren()
- local healthBar, castBar = frame.healthBar, frame.castBar
- local glow, overlay, castbarOverlay, shielded, spellIcon, highlight, nameText, levelText, bossIcon, raidIcon, stateIcon = frame:GetRegions()
- frame.nameOld = nameText
- local name = frame:CreateFontString(nil, "ARTWORK", "ChatFontSmall")
- name:SetPoint("TOPLEFT", 15,0)
- frame.name = name
- healthBar:SetStatusBarTexture("Interface\\AddOns\\DreamsUI\\media\\st")
- healthBar:ClearAllPoints()
- healthBar:SetPoint("TOPLEFT", frame, 15, -15)
- healthBar:SetPoint("BOTTOMRIGHT", frame, -15, 15)
- local castbar = CreateFrame("statusbar", nil, frame)
- castbar:SetScale(UIParent:GetScale())
- castbar:SetStatusBarTexture("Interface\\AddOns\\DreamsUI\\media\\st")
- castbar:SetPoint("TOPLEFT",frame, "BOTTOMLEFT", 28, -10)
- castbar:SetPoint("BOTTOMRIGHT",frame, 0, -20)
- castbar.tex = castbar:CreateTexture(nil, "BACKGROUND")
- castbar.tex:SetTexture(0,0,0,0.75)
- castbar.tex:SetAllPoints()
- local icon = castbar:CreateTexture(nil, "ARTWORK")
- icon:SetSize(25,25)
- icon:SetTexCoord(.08, .92, .08, .92)
- icon:SetPoint("RIGHT", castbar, "LEFT", -3, 0)
- castbar.Icon = icon
- frame.Castbar = castbar
- frame.Castbar:Hide()
- levelText:SetFont(ChatFontNormal:GetFont())
- levelText:SetPoint("TOPRIGHT", -15,0)
- bossIcon:SetPoint("TOPRIGHT", -15,0)
- stateIcon:ClearAllPoints()
- stateIcon:SetPoint("RIGHT",frame, 15, 0)
- highlight:SetTexture(.3,.3,.3)
- highlight:ClearAllPoints()
- highlight:SetAllPoints(healthBar)
- frame.highlight = highlight
- frame.glow = glow
- overlay:SetTexture(nil)
- glow:SetTexture(nil)
- nameText:Hide()
- PlateOnShow(frame)
- frame:SetScript("OnUpdate", PlateOnUpdate)
- frame:RegisterEvent("UNIT_SPELLCAST_START")
- frame:RegisterEvent("UNIT_SPELLCAST_FAILED")
- frame:RegisterEvent("UNIT_SPELLCAST_STOP")
- frame:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
- frame:RegisterEvent("UNIT_SPELLCAST_DELAYED")
- frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
- frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
- frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
- frame:SetScript("OnEvent", PlateOnEvent)
- frame.Castbar:SetScript("OnUpdate", PlateCastbarOnUpdate)
- frame.done = true
- end
- function np:NewNameplate(plate)
- StylePlates(plate)
- PlateOnShow(plate)
- plate.Castbar:Hide()
- if ShouldAddBuffs(plate) == true then
- AddOurStuffToPlate(plate)
- end
- end
- function np:FoundGUID(plate, GUID, unitID)
- if ShouldAddBuffs(plate) == true then
- if not guidBuffs[GUID] then
- self:CollectUnitInfo(unitID)
- end
- RemoveOldSpells(GUID)
- np:AddBuffsToPlate(plate, GUID)
- end
- end
- function np:MouseoverNameplate(mouseoverPlate)
- end
- function np:TargetNameplate(frame)
- end
- function np:RecycleNameplate(plate)
- HidePlateSpells(plate)
- end
- function np:Init()
- for i, event in pairs(regEvents) do
- self:RegisterEvent(event)
- end
- for plate in pairs(buffBars) do
- for i=1, table.getn(buffBars[plate]) do
- buffBars[plate][i]:Show()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment