Clean up code, remove dedundant if clauses, remove comments
This commit is contained in:
parent
89179e1807
commit
e2e49a7816
|
@ -1,11 +1,12 @@
|
|||
local lib = LibStub:NewLibrary("LibCombatLog", 15)
|
||||
local lib = LibStub:NewLibrary("LibCombatLog", 16)
|
||||
if not lib then return end
|
||||
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
|
||||
local CombatLogGetCurrentEventInfo, pairs, unpack, type = CombatLogGetCurrentEventInfo, pairs, unpack, type
|
||||
lib.mixinTargets = lib.mixinTargets or {}
|
||||
local mixins = {"RegisterCLEvent", "UnRegisterCLEvent", "RegisterCLSuffix", "UnRegisterCLSuffix", "RegisterCLStatus", "UnRegisterCLStatus","SplitCLEvent"}
|
||||
lib['regs'] = lib['regs'] or {
|
||||
['PLAYER_REGEN'] = {},
|
||||
}
|
||||
lib['regs']['PLAYER_REGEN'] = lib['regs']['PLAYER_REGEN'] or {}
|
||||
local allPrefix = {
|
||||
'SWING', 'RANGE', 'SPELL_PERIODIC', 'SPELL_BUILDING', 'SPELL', 'ENVIRONMENTAL', 'UNIT', 'PARTY', 'ENCHANT'
|
||||
}
|
||||
|
@ -87,11 +88,9 @@ function lib:RegisterCLSuffix(suffix, funcName)
|
|||
end
|
||||
end
|
||||
function lib:UnRegisterCLSuffix(suffix)
|
||||
if(lib['regs'][suffix]) then
|
||||
if(lib['regs'][suffix][self]) then
|
||||
lib['regs'][suffix][self] = nil
|
||||
if(lib['regs'][suffix]) then
|
||||
lib['regs'][suffix][self] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
function lib:RegisterCLEvent(event,funcName)
|
||||
if(type(event) ~= "string" and funcName) then
|
||||
|
@ -106,22 +105,15 @@ function lib:RegisterCLEvent(event,funcName)
|
|||
end
|
||||
end
|
||||
function lib:RegisterCLStatus(funcName)
|
||||
lib['regs']['PLAYER_REGEN'] = lib['regs']['PLAYER_REGEN'] or {}
|
||||
lib['regs']['PLAYER_REGEN'][self] = funcName
|
||||
end
|
||||
function lib:UnRegisterCLStatus()
|
||||
if(lib['regs']['PLAYER_REGEN']) then
|
||||
if(lib['regs']['PLAYER_REGEN'][self]) then
|
||||
lib['regs']['PLAYER_REGEN'][self] = nil
|
||||
end
|
||||
end
|
||||
lib['regs']['PLAYER_REGEN'][self] = nil
|
||||
end
|
||||
function lib:UnRegisterCLEvent(event)
|
||||
if(lib['regs'][event]) then
|
||||
if(lib['regs'][event][self]) then
|
||||
lib['regs'][event][self] = nil
|
||||
if(lib['regs'][event]) then
|
||||
lib['regs'][event][self] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
function lib:Embed(target)
|
||||
for _,name in pairs(mixins) do
|
||||
|
@ -129,15 +121,6 @@ function lib:Embed(target)
|
|||
end
|
||||
lib.mixinTargets[target] = true
|
||||
end
|
||||
|
||||
for target,_ in pairs(lib.mixinTargets) do
|
||||
for target, _ in pairs(lib.mixinTargets) do
|
||||
lib:Embed(target)
|
||||
end
|
||||
--[[ Debug demo
|
||||
local f = CreateFrame("Frame")
|
||||
f['dmg'] = function(self, ...)
|
||||
print(...)
|
||||
end
|
||||
LibStub("LibCombatLog"):Embed(f)
|
||||
f:RegisterCLSuffix('DAMAGE', 'dmg')
|
||||
]]
|
||||
end
|
Loading…
Reference in New Issue