Skip to content

Commit

Permalink
Classic: Remove LibClassicCasterino
Browse files Browse the repository at this point in the history
UnitCastingInfo/UnitChannelInfo work now on classic
  • Loading branch information
InfusOnWoW committed Dec 17, 2023
1 parent 5bc5411 commit bad3a90
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 81 deletions.
1 change: 0 additions & 1 deletion .pkgmeta
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ externals:
WeakAuras/Libs/LibCustomGlow-1.0: https://github.com/Stanzilla/LibCustomGlow
WeakAuras/Libs/LibDBIcon-1.0: https://repos.curseforge.com/wow/libdbicon-1-0/trunk/LibDBIcon-1.0
WeakAuras/Libs/LibGetFrame-1.0: https://github.com/mrbuds/LibGetFrame
WeakAuras/Libs/LibClassicCasterino: https://github.com/rgd87/LibClassicCasterino
WeakAuras/Libs/Archivist:
url: https://github.com/emptyrivers/Archivist
tag: v1.0.8
Expand Down
3 changes: 0 additions & 3 deletions WeakAuras/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,6 @@ do
"LibSerialize",
"LibUIDropDownMenu-4.0"
}
if WeakAuras.IsClassicEra() then
tinsert(LibStubLibs, "LibClassicCasterino")
end
if WeakAuras.IsRetail() then
tinsert(LibStubLibs, "LibSpecialization")
AddonCompartmentFrame:RegisterAddon({
Expand Down
117 changes: 46 additions & 71 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,83 +86,58 @@ function WeakAuras.UnitDetailedThreatSituation(unit1, unit2)
end
end

local LibClassicCasterino
if WeakAuras.IsClassicEra() then
LibClassicCasterino = LibStub("LibClassicCasterino")
end

if WeakAuras.IsWrathOrRetail() then
WeakAuras.UnitCastingInfo = UnitCastingInfo
else
WeakAuras.UnitCastingInfo = function(unit)
if UnitIsUnit(unit, "player") then
return UnitCastingInfo("player")
else
return LibClassicCasterino:UnitCastingInfo(unit)
end
end
end
WeakAuras.UnitCastingInfo = UnitCastingInfo

if WeakAuras.IsWrathOrRetail() then
if WeakAuras.IsRetail() then
local cacheEmpowered = {}
WeakAuras.UnitChannelInfo = function(unit)
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = UnitChannelInfo(unit)
if name == nil and cacheEmpowered[unit] then
local holdAtMaxTime
holdAtMaxTime, name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = unpack(cacheEmpowered[unit])
if endTime == nil
or holdAtMaxTime == nil
or endTime + holdAtMaxTime < GetTime()
then -- invalid or too old data
cacheEmpowered[unit] = nil
return nil
end
end
return name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages
end
local cacheEmpoweredFrame = CreateFrame("Frame")
cacheEmpoweredFrame:RegisterEvent("UNIT_SPELLCAST_EMPOWER_START")
cacheEmpoweredFrame:RegisterEvent("UNIT_SPELLCAST_EMPOWER_UPDATE")
cacheEmpoweredFrame:RegisterEvent("UNIT_SPELLCAST_EMPOWER_STOP")
cacheEmpoweredFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
cacheEmpoweredFrame:RegisterEvent("PLAYER_SOFT_FRIEND_CHANGED")
cacheEmpoweredFrame:RegisterEvent("PLAYER_SOFT_ENEMY_CHANGED")
cacheEmpoweredFrame:RegisterEvent("PLAYER_FOCUS_CHANGED")
cacheEmpoweredFrame:SetScript("OnEvent", function(_, event, unit, ...)
if Private.player_target_events[event] then
unit = Private.player_target_events[event]
end
if event == "UNIT_SPELLCAST_EMPOWER_START"
or event == "UNIT_SPELLCAST_EMPOWER_UPDATE"
or (
(Private.player_target_events[event])
and (select(10, UnitChannelInfo(unit)) or 0) > 0 -- 10th arg of UnitChannelInfo is numStages for empowered spells
)
then
cacheEmpowered[unit] = {GetUnitEmpowerHoldAtMaxTime(unit), UnitChannelInfo(unit)}
else
if WeakAuras.IsRetail() then
local cacheEmpowered = {}
WeakAuras.UnitChannelInfo = function(unit)
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = UnitChannelInfo(unit)
if name == nil and cacheEmpowered[unit] then
local holdAtMaxTime
holdAtMaxTime, name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages = unpack(cacheEmpowered[unit])
if endTime == nil
or holdAtMaxTime == nil
or endTime + holdAtMaxTime < GetTime()
then -- invalid or too old data
cacheEmpowered[unit] = nil
return nil
end
if unit == "player" and event == "UNIT_SPELLCAST_EMPOWER_START" or event == "UNIT_SPELLCAST_EMPOWER_STOP" then
local castLatencyFrame = Private.frames["Cast Latency Handler"]
if castLatencyFrame then
castLatencyFrame:GetScript("OnEvent")(nil, event, unit, ...)
end
end
WeakAuras.ScanUnitEvents(event.."_FAKE", unit, ...)
end)
else
WeakAuras.UnitChannelInfo = UnitChannelInfo
end
return name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID, _, numStages
end
else
WeakAuras.UnitChannelInfo = function(unit)
if UnitIsUnit(unit, "player") then
return UnitChannelInfo("player")
local cacheEmpoweredFrame = CreateFrame("Frame")
cacheEmpoweredFrame:RegisterEvent("UNIT_SPELLCAST_EMPOWER_START")
cacheEmpoweredFrame:RegisterEvent("UNIT_SPELLCAST_EMPOWER_UPDATE")
cacheEmpoweredFrame:RegisterEvent("UNIT_SPELLCAST_EMPOWER_STOP")
cacheEmpoweredFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
cacheEmpoweredFrame:RegisterEvent("PLAYER_SOFT_FRIEND_CHANGED")
cacheEmpoweredFrame:RegisterEvent("PLAYER_SOFT_ENEMY_CHANGED")
cacheEmpoweredFrame:RegisterEvent("PLAYER_FOCUS_CHANGED")
cacheEmpoweredFrame:SetScript("OnEvent", function(_, event, unit, ...)
if Private.player_target_events[event] then
unit = Private.player_target_events[event]
end
if event == "UNIT_SPELLCAST_EMPOWER_START"
or event == "UNIT_SPELLCAST_EMPOWER_UPDATE"
or (
(Private.player_target_events[event])
and (select(10, UnitChannelInfo(unit)) or 0) > 0 -- 10th arg of UnitChannelInfo is numStages for empowered spells
)
then
cacheEmpowered[unit] = {GetUnitEmpowerHoldAtMaxTime(unit), UnitChannelInfo(unit)}
else
return LibClassicCasterino:UnitChannelInfo(unit)
cacheEmpowered[unit] = nil
end
end
if unit == "player" and event == "UNIT_SPELLCAST_EMPOWER_START" or event == "UNIT_SPELLCAST_EMPOWER_STOP" then
local castLatencyFrame = Private.frames["Cast Latency Handler"]
if castLatencyFrame then
castLatencyFrame:GetScript("OnEvent")(nil, event, unit, ...)
end
end
WeakAuras.ScanUnitEvents(event.."_FAKE", unit, ...)
end)
else
WeakAuras.UnitChannelInfo = UnitChannelInfo
end

local constants = {
Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/WeakAuras.toc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: WeakAurasSaved
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibClassicCasterino, LibGetFrame-1.0, LibSpecialization, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibGetFrame-1.0, LibSpecialization, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core

# External code + initialization
embeds.xml
Expand Down
5 changes: 1 addition & 4 deletions WeakAuras/WeakAuras_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: WeakAurasSaved
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibClassicCasterino, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core

# External code + initialization
embeds.xml

# Client flavor specific libs
Libs\LibClassicCasterino\LibClassicCasterino.lua

Init.lua
locales.xml
ArchiveTypes\Repository.lua
Expand Down
2 changes: 1 addition & 1 deletion WeakAuras/WeakAuras_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: WeakAurasSaved
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibClassicCasterino, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core
## OptionalDeps: Ace3, LibCompress, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, Masque, GTFO, LibButtonGlow-1.0, LibSpellRange-1.0, LibRangeCheck-3.0, LibDBIcon-1.0, LibGetFrame-1.0, !LibUIDropDownMenu, !!AddonLocale, BigWigs, DBM-Core

# External code + initialization
embeds.xml
Expand Down

0 comments on commit bad3a90

Please sign in to comment.