Skip to content

Commit

Permalink
hook OnShow instead of SetShown
Browse files Browse the repository at this point in the history
  • Loading branch information
wardz committed Sep 8, 2024
1 parent d80e85e commit bee4ea2
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ClassicCastbars/ClassicCastbars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function ClassicCastbars:BindCurrentCastData(castbar, unitID, isChanneled, chann

-- HACK: UnitChannelInfo is bugged for classic era, tmp fallback method
if channelSpellID and not spellName then
if C_Spell.GetSpellInfo then
if C_Spell and C_Spell.GetSpellInfo then
local info = C_Spell.GetSpellInfo(channelSpellID)
spellName = info and info.name
iconTexturePath = info and info.iconID
Expand Down Expand Up @@ -254,6 +254,16 @@ function ClassicCastbars:PLAYER_FOCUS_CHANGED()
end
end

local function BlizzNameplateCastbar_OnShow(frame)
if frame:IsProtected() or frame:IsForbidden() then return end
if not frame.unit or not strfind(frame.unit, "nameplate") then return end

if ClassicCastbars.db.nameplate.enabled then
-- Force hide
frame:Hide()
end
end

local GetNamePlateForUnit = C_NamePlate.GetNamePlateForUnit
function ClassicCastbars:NAME_PLATE_UNIT_ADDED(namePlateUnitToken)
if UnitIsUnit("player", namePlateUnitToken) then return end -- personal resource display nameplate
Expand All @@ -266,16 +276,7 @@ function ClassicCastbars:NAME_PLATE_UNIT_ADDED(namePlateUnitToken)

-- Hide Blizz castbar
if not plateCastbar.ClassicCastbarsHooked then
-- Prob an easier way to do this, but this'll have to do for now
hooksecurefunc(plateCastbar, "SetShown", function(frame, show)
if frame:IsProtected() or frame:IsForbidden() then return end
if not frame.unit or not strfind(frame.unit, "nameplate") then return end

if show and ClassicCastbars.db.nameplate.enabled then
-- Force hide
frame:Hide()
end
end)
plateCastbar:HookScript("OnShow", BlizzNameplateCastbar_OnShow)
plateCastbar.ClassicCastbarsHooked = true
end
end
Expand Down

0 comments on commit bee4ea2

Please sign in to comment.