mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-23 08:06:55 +00:00
93 lines
3.4 KiB
Lua
93 lines
3.4 KiB
Lua
-- Compatibility layer to use castbars provided by SuperWoW:
|
|
-- https://github.com/balakethelock/SuperWoW
|
|
|
|
pfUI:RegisterModule("superwow", "vanilla", function ()
|
|
if SetAutoloot and SpellInfo and not SUPERWOW_VERSION then
|
|
-- Turn every enchanting link that we create in the enchanting frame,
|
|
-- from "spell:" back into "enchant:". The enchant-version is what is
|
|
-- used by all unmodified game clients. This is required to generate
|
|
-- usable links for everyone from the enchant frame while having SuperWoW.
|
|
local HookGetCraftItemLink = GetCraftItemLink
|
|
_G.GetCraftItemLink = function(index)
|
|
local link = HookGetCraftItemLink(index)
|
|
return string.gsub(link, "spell:", "enchant:")
|
|
end
|
|
|
|
-- Convert every enchanting link that we receive into a
|
|
-- spell link, as for some reason SuperWoW can't handle
|
|
-- enchanting links at all and requires it to be a spell.
|
|
local HookSetItemRef = SetItemRef
|
|
_G.SetItemRef = function(link, text, button)
|
|
link = string.gsub(link, "enchant:", "spell:")
|
|
HookSetItemRef(link, text, button)
|
|
end
|
|
|
|
local HookGameTooltipSetHyperlink = GameTooltip.SetHyperlink
|
|
_G.GameTooltip.SetHyperlink = function(self, link)
|
|
link = string.gsub(link, "enchant:", "spell:")
|
|
HookGameTooltipSetHyperlink(self, link)
|
|
end
|
|
|
|
DEFAULT_CHAT_FRAME:AddMessage("|cffffffaaAn old version of SuperWoW was detected. Please consider updating:")
|
|
DEFAULT_CHAT_FRAME:AddMessage("-> https://github.com/balakethelock/SuperWoW/releases/")
|
|
end
|
|
|
|
local unitcast = CreateFrame("Frame")
|
|
unitcast:RegisterEvent("UNIT_CASTEVENT")
|
|
unitcast:SetScript("OnEvent", function()
|
|
if arg3 == "START" or arg3 == "CAST" or arg3 == "CHANNEL" 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"
|
|
|
|
-- skip on buff procs during cast
|
|
if event_type == "CAST" then
|
|
if not libcast.db[guid] or libcast.db[guid].cast ~= spell then
|
|
-- ignore casts without 'START' event, while there is already another cast.
|
|
-- those events can be for example a frost shield proc while casting frostbolt.
|
|
-- we want to keep the cast itself, so we simply skip those.
|
|
return
|
|
end
|
|
end
|
|
|
|
-- 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 = event_type == "CHANNEL" or false
|
|
|
|
-- write state variable
|
|
superwow_active = true
|
|
elseif arg3 == "FAIL" then
|
|
local guid = arg1
|
|
|
|
-- delete all cast entries of guid
|
|
if libcast.db[guid] then
|
|
libcast.db[guid].cast = nil
|
|
libcast.db[guid].rank = nil
|
|
libcast.db[guid].start = nil
|
|
libcast.db[guid].casttime = nil
|
|
libcast.db[guid].icon = nil
|
|
libcast.db[guid].channel = nil
|
|
end
|
|
end
|
|
end)
|
|
end)
|