|
1 | 1 | local MAJOR_VERSION = "LibGetFrame-1.0"
|
2 |
| -local MINOR_VERSION = 10 |
| 2 | +local MINOR_VERSION = 11 |
3 | 3 | if not LibStub then error(MAJOR_VERSION .. " requires LibStub.") end
|
4 | 4 | local lib = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
|
5 | 5 | if not lib then return end
|
@@ -220,35 +220,35 @@ end
|
220 | 220 | lib.GetFrame = lib.GetUnitFrame -- compatibility
|
221 | 221 |
|
222 | 222 | -- nameplates
|
223 |
| - |
224 |
| -local statusBars = {} |
225 |
| -local function GetChildrenStatusBars(frame, ...) |
226 |
| - if not frame then return end |
227 |
| - local frameType = frame:GetObjectType() |
228 |
| - if frameType == "Frame" or frameType == "Button" then |
229 |
| - GetChildrenStatusBars(frame:GetChildren()) |
230 |
| - end |
231 |
| - if frameType == "StatusBar" and frame:IsVisible() then |
232 |
| - tinsert(statusBars, frame) |
233 |
| - end |
234 |
| - GetChildrenStatusBars(...) |
235 |
| -end |
236 |
| - |
237 | 223 | function lib.GetUnitNameplate(unit)
|
238 | 224 | if not unit then return end
|
239 |
| - local frame = C_NamePlate.GetNamePlateForUnit(unit) |
240 |
| - if not frame then return end |
241 |
| - wipe(statusBars) |
242 |
| - GetChildrenStatusBars(frame) |
243 |
| - if #statusBars == 0 then |
244 |
| - return frame |
245 |
| - else |
246 |
| - for _, child in pairs(statusBars) do |
247 |
| - local name = child:GetName() |
248 |
| - if name and name:lower():find("health") then |
249 |
| - return child |
250 |
| - end |
| 225 | + local nameplate = C_NamePlate.GetNamePlateForUnit(unit) |
| 226 | + if nameplate then |
| 227 | + -- credit to Exality for https://wago.io/explosiveorbs |
| 228 | + if nameplate.unitFrame and nameplate.unitFrame.HealthBar then |
| 229 | + -- elvui |
| 230 | + return nameplate.unitFrame.HealthBar |
| 231 | + elseif nameplate.unitFramePlater then |
| 232 | + -- plater |
| 233 | + return nameplate.unitFramePlater.healthBar |
| 234 | + elseif nameplate.kui then |
| 235 | + -- kui |
| 236 | + return nameplate.kui.HealthBar |
| 237 | + elseif nameplate.extended then |
| 238 | + -- tidyplates |
| 239 | + --nameplate.extended.visual.healthbar:SetHeight(tidyplatesHeight) |
| 240 | + return nameplate.extended.visual.healthbar |
| 241 | + elseif nameplate.TPFrame then |
| 242 | + -- tidyplates: threat plates |
| 243 | + return nameplate.TPFrame.visual.healthbar |
| 244 | + elseif nameplate.ouf then |
| 245 | + -- bdNameplates |
| 246 | + return nameplate.ouf.Health |
| 247 | + elseif nameplate.UnitFrame then |
| 248 | + -- default |
| 249 | + return nameplate.UnitFrame.healthBar |
| 250 | + else |
| 251 | + return nameplate |
251 | 252 | end
|
252 |
| - return statusBars[1] |
253 | 253 | end
|
254 | 254 | end
|
0 commit comments