Quantcast WoWInterface: SVN - LibWombat - Path Comparison - / Rev 1 and / Rev 2

WoWInterface SVN LibWombat

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 1 to Rev 2
    Reverse comparison

Rev 1 → Rev 2

trunk/LibWombat.lua New file
0,0 → 1,53
local wombat = LibStub:NewLibrary("LibWombat",20080809);
if (not wombat) then LIBWOMBAT_GLOBAL = {}; local wombat = LIBWOMBAT_GLOBAL; end
----------------------------------------------------------------------------------------------------
local watcher = getglobal("LibWombatWatcherFrame") or CreateFrame("Frame","LibWombatWatcherFrame");
watcher:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
wombat.parser = wombat.parser or {};
local CleanParser = function()
for event,list in pairs(wombat.parser) do
local exists = false;
for serial,callback in pairs(list) do exists = true; end
if (not exists) then wombat.parser[event] = nil; end
end
end;
wombat.StartParsing = function(self,event,method)
if (type(event) ~= "string") or (type(method) ~= "function") then return; end
wombat.parser[event] = wombat.parser[event] or {};
wombat.parser[event][self] = method;
end;
wombat.StopParsing = function(self,event)
if (not wombat.parser[event]) then return; end
wombat.parser[event][self] = nil;
CleanParser();
end;
wombat.StopAllParsing = function(self)
for event,list in pairs(wombat.parser) do
if (list[self]) then wombat.parser[event][self] = nil; end
end
CleanParser();
end;
----------------------------------------------------------------------------------------------------
function wombat:NewParser(target)
target.StartParsing = wombat.StartParsing;
target.StopParsing = wombat.StopParsing;
target.StopAllParsing = wombat.StopAllParsing;
end
----------------------------------------------------------------------------------------------------
watcher:SetScript("OnEvent",function(__,event,when,what,srcGUID,srcNAME,srcFLAGS,destGUID,destNAME,destFLAGS,...)
if (event == "COMBAT_LOG_EVENT_UNFILTERED") then
if (wombat.parser[what]) then
for k,callback in pairs(wombat.parser[what]) do
callback(when,what,srcGUID,srcNAME,srcFLAGS,destGUID,destNAME,destFLAGS,...);
end
end
end
end);
----------------------------------------------------------------------------------------------------
--[[ some usage examples
local MyAddon = {};
wombat:NewParser(MyAddon);
MyAddon:StartParsing("SWING_DAMAGE",function(when,what,sGUID,sNAME)
DEFAULT_CHAT_FRAME:AddMessage("SWING_DAMAGE ("..sNAME..")");
end);
]]
\ No newline at end of file
trunk/LibStub.lua New file
0,0 → 1,30
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS!
local LibStub = _G[LIBSTUB_MAJOR]
 
if not LibStub or LibStub.minor < LIBSTUB_MINOR then
LibStub = LibStub or {libs = {}, minors = {} }
_G[LIBSTUB_MAJOR] = LibStub
LibStub.minor = LIBSTUB_MINOR
 
function LibStub:NewLibrary(major, minor)
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)")
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.")
 
local oldminor = self.minors[major]
if oldminor and oldminor >= minor then return nil end
self.minors[major], self.libs[major] = minor, self.libs[major] or {}
return self.libs[major], oldminor
end
 
function LibStub:GetLibrary(major, silent)
if not self.libs[major] and not silent then
error(("Cannot find a library instance of %q."):format(tostring(major)), 2)
end
return self.libs[major], self.minors[major]
end
 
function LibStub:IterateLibraries() return pairs(self.libs) end
setmetatable(LibStub, { __call = LibStub.GetLibrary })
end
trunk/LibWombat.toc New file
0,0 → 1,9
## Interface: 30000
## Title: Lib: Wombat
## Notes: Wombat is a Combat Watcher. It basically dispatches combat events that the author is interested in, and sends the resulting raw data to a callback handler of the author's choosing.
## Version 30000.4
## Author: Beladona
## OptionalDeps: LibStub
 
LibStub.lua
LibWombat.lua