|
1 | 1 | local _, ns = ... |
2 | 2 | local OVERSHIELD_TICK_OFFSET = -7 |
3 | 3 |
|
4 | | --- Hook into the base UI function to clear points before it sets them |
5 | | -hooksecurefunc("CompactUnitFrameUtil_UpdateFillBar", function(frame, previousTexture, bar, amount, barOffsetXPercent) |
6 | | - if type(bar) == "userdata" |
7 | | - and bar.ClearAllPoints |
8 | | - and not (bar.IsForbidden and bar:IsForbidden()) |
9 | | - then |
10 | | - -- TODO: Handle error - determine if needed? |
11 | | - -- (discarded) success, error |
12 | | - local _, _ = pcall(function() |
| 4 | +local function clearAllPoints(bar) |
| 5 | + -- TODO: Catch error - determine if handling needed? |
| 6 | + -- _, (discarded) error |
| 7 | + local success, _ = pcall(function() |
| 8 | + if bar.ClearAllPoints and not (bar.IsForbidden and bar:IsForbidden()) then |
13 | 9 | bar:ClearAllPoints() |
14 | | - end) |
| 10 | + end |
| 11 | + end) |
| 12 | + if not success then |
| 13 | + print("[OSR] CompactUnitFrameUtil_UpdateFillBar: ClearAllPoints produced an error for: ", bar:GetName()) |
| 14 | + print("[OSR] Please report this! (https://github.com/creed-us/Overshields_Reforged).") |
15 | 15 | end |
16 | | -end) |
| 16 | +end |
17 | 17 |
|
18 | 18 | ns.HandleCompactUnitFrame_Update = function(frame) |
19 | 19 | local db = OvershieldsReforged.db.profile |
@@ -62,7 +62,8 @@ ns.HandleCompactUnitFrame_Update = function(frame) |
62 | 62 |
|
63 | 63 | -- Handle overshieldTick prior to shieldOverlay and shieldBar to ensure correct visibility |
64 | 64 | if hasOvershield then |
65 | | - overshieldTick:ClearAllPoints() |
| 65 | + clearAllPoints(overshieldTick) |
| 66 | + --overshieldTick:ClearAllPoints() |
66 | 67 | if hasMissingHealth then |
67 | 68 | overshieldTick:SetPoint("TOPLEFT", healthBar, "TOPRIGHT", OVERSHIELD_TICK_OFFSET, 0) |
68 | 69 | overshieldTick:SetPoint("BOTTOMLEFT", healthBar, "BOTTOMRIGHT", OVERSHIELD_TICK_OFFSET, 0) |
@@ -92,7 +93,8 @@ ns.HandleCompactUnitFrame_Update = function(frame) |
92 | 93 |
|
93 | 94 |
|
94 | 95 | -- Handle shieldOverlay visibility and positioning |
95 | | - shieldOverlay:ClearAllPoints() |
| 96 | + clearAllPoints(shieldOverlay) |
| 97 | + --shieldOverlay:ClearAllPoints() |
96 | 98 | shieldOverlay:SetParent(healthBar) |
97 | 99 | -- Apply the texture and ensure proper tiling |
98 | 100 | local tileSize = shieldOverlay.tileSize or 128 |
@@ -122,6 +124,7 @@ ns.HandleCompactUnitFrame_Update = function(frame) |
122 | 124 | end |
123 | 125 |
|
124 | 126 | -- Handle shieldBar visibility and positioning |
| 127 | + clearAllPoints(shieldBar) |
125 | 128 | shieldBar:ClearAllPoints() |
126 | 129 | -- Apply custom color/alpha, blend mode, and texture to shieldBar |
127 | 130 | local shieldBarColor = db.shieldBarColor |
|
0 commit comments