annotate ReAction.lua @ 25:bf997ea151ca

yet another attempt to add missing files
author Flick <flickerstreak@gmail.com>
date Fri, 07 Mar 2008 22:19:03 +0000
parents
children f1e838841ce1
rev   line source
flickerstreak@25 1 --[[
flickerstreak@25 2
flickerstreak@25 3 ReAction Add-On main file.
flickerstreak@25 4
flickerstreak@25 5 Performs add-on and library initialization and setup.
flickerstreak@25 6
flickerstreak@25 7 --]]
flickerstreak@25 8
flickerstreak@25 9
flickerstreak@25 10 -- 'ReAction' is exported as a global.
flickerstreak@25 11 ReAction = AceLibrary("AceAddon-2.0"):new(
flickerstreak@25 12 "AceModuleCore-2.0",
flickerstreak@25 13 "AceEvent-2.0",
flickerstreak@25 14 "AceDB-2.0"
flickerstreak@25 15 )
flickerstreak@25 16
flickerstreak@25 17 local ReAction = ReAction
flickerstreak@25 18 local L = AceLibrary("AceLocale-2.2"):new("ReAction")
flickerstreak@25 19 local AceOO = AceLibrary("AceOO-2.0")
flickerstreak@25 20
flickerstreak@25 21
flickerstreak@25 22 ReAction.revision = tonumber(("$Revision: 1 $"):match("%d+"))
flickerstreak@25 23 ReAction.L = L
flickerstreak@25 24
flickerstreak@25 25 -- global variable strings for integration with WoW keybindings dialog (see bindings.xml)
flickerstreak@25 26 BINDING_HEADER_REACTION = L["ReAction"]
flickerstreak@25 27 BINDING_NAME_REACTION_TOGGLELOCK = L["Toggle ReAction Bar Lock"]
flickerstreak@25 28 BINDING_NAME_REACTION_TOGGLEKEYBIND = L["ReAction Keybinding Mode"]
flickerstreak@25 29
flickerstreak@25 30 -- from AceAddon-2.0
flickerstreak@25 31 function ReAction:OnInitialize()
flickerstreak@25 32 self:RegisterDB("ReActionDB")
flickerstreak@25 33 end
flickerstreak@25 34
flickerstreak@25 35 -- from AceAddon-2.0
flickerstreak@25 36 function ReAction:OnEnable()
flickerstreak@25 37
flickerstreak@25 38 end
flickerstreak@25 39
flickerstreak@25 40 -- from AceAddon-2.0
flickerstreak@25 41 function ReAction:OnDisable()
flickerstreak@25 42
flickerstreak@25 43 end
flickerstreak@25 44
flickerstreak@25 45 -- from AceDB-2.0
flickerstreak@25 46 function ReAction:OnProfileEnable()
flickerstreak@25 47
flickerstreak@25 48 end
flickerstreak@25 49
flickerstreak@25 50 -- from AceDB-2.0
flickerstreak@25 51 function ReAction:OnProfileDisable()
flickerstreak@25 52
flickerstreak@25 53 end
flickerstreak@25 54
flickerstreak@25 55 -- from AceModuleCore-2.0
flickerstreak@25 56 function ReAction:OnModuleEnable(module)
flickerstreak@25 57 -- this handles initialization ordering issues with ReAction_Bar
flickerstreak@25 58 local barMod = self:GetModule("Bar")
flickerstreak@25 59 if barMod and module.ApplyToBar then
flickerstreak@25 60 for _, b in pairs(barMod.bars) do
flickerstreak@25 61 if b then
flickerstreak@25 62 module:ApplyToBar(b)
flickerstreak@25 63 end
flickerstreak@25 64 end
flickerstreak@25 65 end
flickerstreak@25 66 end
flickerstreak@25 67
flickerstreak@25 68 -- from AceModuleCore-2.0
flickerstreak@25 69 function ReAction:OnModuleDisable(module)
flickerstreak@25 70 local barMod = self:GetModule("Bar")
flickerstreak@25 71 if barMod and module.RemoveFromBar then
flickerstreak@25 72 for _, b in pairs(barMod.bars) do
flickerstreak@25 73 if b then
flickerstreak@25 74 module:RemoveFromBar(b)
flickerstreak@25 75 end
flickerstreak@25 76 end
flickerstreak@25 77 end
flickerstreak@25 78 end
flickerstreak@25 79
flickerstreak@25 80 --[[
flickerstreak@25 81 Module API (see bar.lua for usage)
flickerstreak@25 82
flickerstreak@25 83 module:ApplyToBar(bar)
flickerstreak@25 84 module:RemoveFromBar(bar)
flickerstreak@25 85 module:RefreshBar(bar)
flickerstreak@25 86 module:ApplyConfigMode(mode,listOfBars)
flickerstreak@25 87 module:GetBarNameModifier(bar)
flickerstreak@25 88 module:EraseBarConfig(barName)
flickerstreak@25 89 ]]--
flickerstreak@25 90
flickerstreak@25 91
flickerstreak@25 92 -- debugging
flickerstreak@25 93 ReAction.debug = true
flickerstreak@25 94 if ReAction.debug then
flickerstreak@25 95 ReAction.print = function(msg)
flickerstreak@25 96 DEFAULT_CHAT_FRAME:AddMessage(msg)
flickerstreak@25 97 end
flickerstreak@25 98 --seterrorhandler(ReAction.print)
flickerstreak@25 99 else
flickerstreak@25 100 ReAction.print = function() end
flickerstreak@25 101 end
flickerstreak@25 102
flickerstreak@25 103
flickerstreak@25 104 -- utility
flickerstreak@25 105 local newTable, recycle, deepCopy, deepDelete, varName
flickerstreak@25 106 do
flickerstreak@25 107 local pool = setmetatable( { }, {__mode="kv"} )
flickerstreak@25 108
flickerstreak@25 109 function newTable(...)
flickerstreak@25 110 local t = table.remove(pool) or { }
flickerstreak@25 111 for i = 1, select('#',...), 2 do
flickerstreak@25 112 local k = select(i,...)
flickerstreak@25 113 local v = select(i+1,...)
flickerstreak@25 114 if k and v then
flickerstreak@25 115 t[k] = v
flickerstreak@25 116 end
flickerstreak@25 117 end
flickerstreak@25 118 return t
flickerstreak@25 119 end
flickerstreak@25 120
flickerstreak@25 121 function recycle(t)
flickerstreak@25 122 if type(t) == "table" then
flickerstreak@25 123 table.insert(pool,t)
flickerstreak@25 124 end
flickerstreak@25 125 end
flickerstreak@25 126
flickerstreak@25 127 function deepCopy( x )
flickerstreak@25 128 if type(x) ~= "table" then
flickerstreak@25 129 return x
flickerstreak@25 130 end
flickerstreak@25 131 local r = newTable()
flickerstreak@25 132 for k,v in pairs(x) do
flickerstreak@25 133 r[k] = deepCopy(v)
flickerstreak@25 134 end
flickerstreak@25 135 return r
flickerstreak@25 136 end
flickerstreak@25 137
flickerstreak@25 138 function deepDelete( x )
flickerstreak@25 139 if type(x) == "table" and x.IsObjectType == nil and not(AceOO.inherits(x,AceOO.Object)) then -- don't want to delete WoW or AceOO objects!
flickerstreak@25 140 for k,v in pairs(x) do
flickerstreak@25 141 x[k] = deepDelete(v)
flickerstreak@25 142 end
flickerstreak@25 143 recycle(x)
flickerstreak@25 144 end
flickerstreak@25 145 end
flickerstreak@25 146
flickerstreak@25 147 function varName(s)
flickerstreak@25 148 return tostring(s):gsub("[^a-zA-Z0-9_]","_")
flickerstreak@25 149 end
flickerstreak@25 150
flickerstreak@25 151 local u = setmetatable( { }, {__newindex = function(self,k,v) rawset(self,#self+1,v) ; rawset(self,k,v) end} )
flickerstreak@25 152 u.deepCopy = deepCopy
flickerstreak@25 153 u.deepDelete = deepDelete
flickerstreak@25 154 u.newTable = newTable
flickerstreak@25 155 u.recycle = recycle
flickerstreak@25 156 u.varName = varName
flickerstreak@25 157
flickerstreak@25 158 ReAction.util = u
flickerstreak@25 159 end
flickerstreak@25 160
flickerstreak@25 161 function ReAction:GetUtilFuncs()
flickerstreak@25 162 return unpack(self.util)
flickerstreak@25 163 end
flickerstreak@25 164