Skip to content

Commit

Permalink
thirdparty: add support for superwow spell cast
Browse files Browse the repository at this point in the history
  • Loading branch information
shagu committed May 9, 2024
1 parent f7c8fdd commit 59878b3
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("thirdparty", "twt", "dock", "0")
pfUI:UpdateConfig("thirdparty", "wim", "enable", "1")
pfUI:UpdateConfig("thirdparty", "healcomm", "enable", "1")
pfUI:UpdateConfig("thirdparty", "superwow", "enable", "1")
pfUI:UpdateConfig("thirdparty", "sortbags", "enable", "1")
pfUI:UpdateConfig("thirdparty", "bag_sort", "enable", "1")
pfUI:UpdateConfig("thirdparty", "mrplow", "enable", "1")
Expand Down
6 changes: 6 additions & 0 deletions modules/castbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function ()
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(this.unitstr or this.unitname)
end

-- read enemy casts from SuperWoW if enabled
if superwow_active and this.unitstr and not UnitIsUnit(this.unitstr, 'player') then
local _, guid = UnitExists(this.unitstr)
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(guid)
end

if cast then
local duration = endTime - startTime
local max = duration / 1000
Expand Down
1 change: 1 addition & 0 deletions modules/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function ()
CreateConfig(nil, "TW Threatmeter (" .. T["Dock"] .. ")", C.thirdparty.twt, "dock", "checkbox", nil, nil, nil, nil, "vanilla")
CreateConfig(nil, "WIM", C.thirdparty.wim, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
CreateConfig(nil, "HealComm", C.thirdparty.healcomm, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
CreateConfig(nil, "SuperWoW", C.thirdparty.superwow, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
CreateConfig(nil, "SortBags", C.thirdparty.sortbags, "enable", "checkbox", nil, nil, nil, nil, "vanilla")
CreateConfig(nil, "Bag_Sort", C.thirdparty.bag_sort, "enable", "checkbox", nil, nil, nil, nil, "tbc")
CreateConfig(nil, "MrPlow", C.thirdparty.mrplow, "enable", "checkbox")
Expand Down
5 changes: 5 additions & 0 deletions modules/nameplates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,11 @@ pfUI:RegisterModule("nameplates", "vanilla:tbc", function ()
if C.nameplates["showcastbar"] == "1" and ( C.nameplates["targetcastbar"] == "0" or target ) then
local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(target and "target" or name)

-- read enemy casts from SuperWoW if enabled
if superwow_active then
cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(nameplate.parent:GetName(1))
end

if not cast then
nameplate.castbar:Hide()
elseif cast then
Expand Down
43 changes: 43 additions & 0 deletions modules/thirdparty-vanilla.lua
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,49 @@ pfUI:RegisterModule("thirdparty-vanilla", "vanilla", function()
end)
end)

-- SuperWoW
-- Vanilla: https://github.com/balakethelock/SuperWoW
HookAddonOrVariable("SpellInfo", function()
if C.thirdparty.superwow.enable == "0" then return end

-- add UnitGUID based casting info to libcast
local unitcast = CreateFrame("Frame")
unitcast:RegisterEvent("UNIT_CASTEVENT")
unitcast:SetScript("OnEvent", function()
if event == "UNIT_CASTEVENT" and arg3 == "START" then
-- human readable argument list
local guid = arg1
local target = arg2
local event_type = arg3
local spell_id = arg4
local timer = arg5
local start = GetTime()

-- get spell info from spell id
local spell, icon, _
if SpellInfo and SpellInfo(spell_id) then
spell, _, icon = SpellInfo(spell_id)
end

-- set fallback values
spell = spell or UNKNOWN
icon = icon or "Interface\\Icons\\INV_Misc_QuestionMark"

-- add cast action to the database
if not libcast.db[guid] then libcast.db[guid] = {} end
libcast.db[guid].cast = spell
libcast.db[guid].rank = nil
libcast.db[guid].start = GetTime()
libcast.db[guid].casttime = timer
libcast.db[guid].icon = icon
libcast.db[guid].channel = false

-- write state variable
superwow_active = true
end
end)
end)

-- SortBags
-- Vanilla: https://github.com/shirsig/SortBags-vanilla
HookAddonOrVariable("SortBags", function()
Expand Down

0 comments on commit 59878b3

Please sign in to comment.