WoWInterface SVN DotIt

[/] [trunk/] [DotIt/] [bossmods.lua] - Rev 20

Compare with Previous | Blame | View Log

if not DotIt then
        error("DotIt has to be loaded first")
end

local newList, del, deepDel, deepCopy = DotIt.sb:GetRecyclingFunctions()
local bossmods = DotIt:NewModule("bossmods")
local ctab = {
        [1] = {r = 1, g = 0, b = 0, a = 0.25},
        [2] = {r = 0, g = 1, b = 0, a = 0.25},
        [3] = {r = 0, g = 0, b = 1, a = 0.25},
        [4] = {r = 1, g = 1, b = 1, a = 0.25},
        [5] = {r = 205/255, g = 127/255, b = 50/255, a = 0.25 },
        [6] = {r = 0, g = 100/255, b = 0, a = 0.25 },
        [7] = {r = 1, g = 20/255, b = 147/255, a = 0.25 },
        [8] = {r = 1, g = 1, b = 0, a = 0.25},
}

local count = 0
local function getColor()
        count = count + 1
        if count > #ctab then count = 1 end
        return ctab[count]
end
function DotIt:removeColor()
        count = count - 1
end
local function dbmHook(self, timer, id, icon, huge, small, color)
        if DotIt.db.profile.ebossmods then
                local color = getColor()
                if string.find(id, "dummy") then return end -- should prevent this strange behavior
                DotIt.sb:CreateBar(id, timer, 0, id, icon, DotIt:GetBarPos(0, "Bossmods"), deepCopy(color), deepCopy(color), DotIt.db.profile.bartexture, function() DotIt:removeColor() end)
                if not DotIt.db.profile.hidebossmod then
                        DotIt.hooks[self]["CreateBar"](self, timer, id, icon, huge, small, color)
                end
        else
                DotIt.hooks[self]["CreateBar"](self, timer, id, icon, huge, small, color)
        end
end
local function bigwigs(self, id, dur, icon)
        if DotIt.db.profile.ebossmods then
                local color = getColor()
                DotIt.sb:CreateBar(id, dur, 0, id, icon, DotIt:GetBarPos(0, "Bossmods"), deepCopy(color), deepCopy(color), DotIt.db.profile.bartexture, function() DotIt:removeColor() end)
        end
end
function DotIt:ADDON_LOADED(self, addon)
        if DotIt.db.profile.ebossmods and DotIt.db.profile.hidebossmod then
                if addon == "BigWigs_Plugins" then
                        DotIt:ScheduleTimer(function() BigWigs:ToggleModuleActive("Bars", false) end, 2)
                end
        end
end
local function setupHooks()
        if IsAddOnLoaded("BigWigs") then
                AceLibrary("AceEvent-2.0"):RegisterEvent("BigWigs_StartBar", bigwigs)
                DotIt:RegisterEvent("ADDON_LOADED")
        elseif IsAddOnLoaded("DBM-Core") then
                DotIt:RawHook(DBM.Bars, "CreateBar", function(...) dbmHook(...) end)
        end
end

function bossmods:OnInitialize()
        if not DotIt.db.profile.ebossmods then return end
        setupHooks()
end

Compare with Previous | Blame