Skip to content

Commit

Permalink
hardcoded values version of GetUnitNameplate
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuds committed Mar 6, 2020
1 parent dc3bf45 commit 8769357
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions LibGetFrame-1.0.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local MAJOR_VERSION = "LibGetFrame-1.0"
local MINOR_VERSION = 10
local MINOR_VERSION = 11
if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
if not lib then return end
Expand Down Expand Up @@ -220,35 +220,35 @@ end
lib.GetFrame = lib.GetUnitFrame -- compatibility

-- nameplates

local statusBars = {}
local function GetChildrenStatusBars(frame, ...)
if not frame then return end
local frameType = frame:GetObjectType()
if frameType == "Frame" or frameType == "Button" then
GetChildrenStatusBars(frame:GetChildren())
end
if frameType == "StatusBar" and frame:IsVisible() then
tinsert(statusBars, frame)
end
GetChildrenStatusBars(...)
end

function lib.GetUnitNameplate(unit)
if not unit then return end
local frame = C_NamePlate.GetNamePlateForUnit(unit)
if not frame then return end
wipe(statusBars)
GetChildrenStatusBars(frame)
if #statusBars == 0 then
return frame
else
for _, child in pairs(statusBars) do
local name = child:GetName()
if name and name:lower():find("health") then
return child
end
local nameplate = C_NamePlate.GetNamePlateForUnit(unit)
if nameplate then
-- credit to Exality for https://wago.io/explosiveorbs
if nameplate.unitFrame and nameplate.unitFrame.HealthBar then
-- elvui
return nameplate.unitFrame.HealthBar
elseif nameplate.unitFramePlater then
-- plater
return nameplate.unitFramePlater.healthBar
elseif nameplate.kui then
-- kui
return nameplate.kui.HealthBar
elseif nameplate.extended then
-- tidyplates
--nameplate.extended.visual.healthbar:SetHeight(tidyplatesHeight)
return nameplate.extended.visual.healthbar
elseif nameplate.TPFrame then
-- tidyplates: threat plates
return nameplate.TPFrame.visual.healthbar
elseif nameplate.ouf then
-- bdNameplates
return nameplate.ouf.Health
elseif nameplate.UnitFrame then
-- default
return nameplate.UnitFrame.healthBar
else
return nameplate
end
return statusBars[1]
end
end

0 comments on commit 8769357

Please sign in to comment.