Skip to content

Commit 59878b3

Browse files
committed
thirdparty: add support for superwow spell cast
1 parent f7c8fdd commit 59878b3

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

api/config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ function pfUI:LoadConfig()
768768
pfUI:UpdateConfig("thirdparty", "twt", "dock", "0")
769769
pfUI:UpdateConfig("thirdparty", "wim", "enable", "1")
770770
pfUI:UpdateConfig("thirdparty", "healcomm", "enable", "1")
771+
pfUI:UpdateConfig("thirdparty", "superwow", "enable", "1")
771772
pfUI:UpdateConfig("thirdparty", "sortbags", "enable", "1")
772773
pfUI:UpdateConfig("thirdparty", "bag_sort", "enable", "1")
773774
pfUI:UpdateConfig("thirdparty", "mrplow", "enable", "1")

modules/castbar.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function ()
9090
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(this.unitstr or this.unitname)
9191
end
9292

93+
-- read enemy casts from SuperWoW if enabled
94+
if superwow_active and this.unitstr and not UnitIsUnit(this.unitstr, 'player') then
95+
local _, guid = UnitExists(this.unitstr)
96+
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(guid)
97+
end
98+
9399
if cast then
94100
local duration = endTime - startTime
95101
local max = duration / 1000

modules/gui.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
22712271
CreateConfig(nil, "TW Threatmeter (" .. T["Dock"] .. ")", C.thirdparty.twt, "dock", "checkbox", nil, nil, nil, nil, "vanilla")
22722272
CreateConfig(nil, "WIM", C.thirdparty.wim, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
22732273
CreateConfig(nil, "HealComm", C.thirdparty.healcomm, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
2274+
CreateConfig(nil, "SuperWoW", C.thirdparty.superwow, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
22742275
CreateConfig(nil, "SortBags", C.thirdparty.sortbags, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
22752276
CreateConfig(nil, "Bag_Sort", C.thirdparty.bag_sort, "enable", "checkbox", nil, nil, nil, nil, "tbc")
22762277
CreateConfig(nil, "MrPlow", C.thirdparty.mrplow, "enable", "checkbox")

modules/nameplates.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,11 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
892892
if C.nameplates["showcastbar"] == "1" and ( C.nameplates["targetcastbar"] == "0" or target ) then
893893
local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(target and "target" or name)
894894

895+
-- read enemy casts from SuperWoW if enabled
896+
if superwow_active then
897+
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(nameplate.parent:GetName(1))
898+
end
899+
895900
if not cast then
896901
nameplate.castbar:Hide()
897902
elseif cast then

modules/thirdparty-vanilla.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,49 @@ pfUI:RegisterModule("thirdparty-vanilla", "vanilla", function()
796796
end)
797797
end)
798798

799+
-- SuperWoW
800+
-- Vanilla: https://github.com/balakethelock/SuperWoW
801+
HookAddonOrVariable("SpellInfo", function()
802+
if C.thirdparty.superwow.enable == "0" then return end
803+
804+
-- add UnitGUID based casting info to libcast
805+
local unitcast = CreateFrame("Frame")
806+
unitcast:RegisterEvent("UNIT_CASTEVENT")
807+
unitcast:SetScript("OnEvent", function()
808+
if event == "UNIT_CASTEVENT" and arg3 == "START" then
809+
-- human readable argument list
810+
local guid = arg1
811+
local target = arg2
812+
local event_type = arg3
813+
local spell_id = arg4
814+
local timer = arg5
815+
local start = GetTime()
816+
817+
-- get spell info from spell id
818+
local spell, icon, _
819+
if SpellInfo and SpellInfo(spell_id) then
820+
spell, _, icon = SpellInfo(spell_id)
821+
end
822+
823+
-- set fallback values
824+
spell = spell or UNKNOWN
825+
icon = icon or "Interface\\Icons\\INV_Misc_QuestionMark"
826+
827+
-- add cast action to the database
828+
if not libcast.db[guid] then libcast.db[guid] = {} end
829+
libcast.db[guid].cast = spell
830+
libcast.db[guid].rank = nil
831+
libcast.db[guid].start = GetTime()
832+
libcast.db[guid].casttime = timer
833+
libcast.db[guid].icon = icon
834+
libcast.db[guid].channel = false
835+
836+
-- write state variable
837+
superwow_active = true
838+
end
839+
end)
840+
end)
841+
799842
-- SortBags
800843
-- Vanilla: https://github.com/shirsig/SortBags-vanilla
801844
HookAddonOrVariable("SortBags", function()

0 commit comments

Comments
 (0)