comparison ReAction.lua @ 27:f1e838841ce1

Rearranged file tree, removed unused code for 1.x start-point
author Flick <flickerstreak@gmail.com>
date Tue, 11 Mar 2008 21:39:34 +0000
parents bf997ea151ca
children 21bcaf8215ff
comparison
equal deleted inserted replaced
26:261f0f6bd68a 27:f1e838841ce1
1 --[[ 1 --[[
2
3 ReAction Add-On main file. 2 ReAction Add-On main file.
4
5 Performs add-on and library initialization and setup. 3 Performs add-on and library initialization and setup.
6
7 --]] 4 --]]
8 5
6 ------ LOCALIZATION ----------
7 local L = AceLibrary("AceLocale-2.2"):new("ReAction")
9 8
9
10 ------ GLOBAL VARIABLES ------
10 -- 'ReAction' is exported as a global. 11 -- 'ReAction' is exported as a global.
11 ReAction = AceLibrary("AceAddon-2.0"):new( 12 ReAction = AceLibrary("AceAddon-2.0"):new(
12 "AceModuleCore-2.0", 13 "AceModuleCore-2.0",
13 "AceEvent-2.0", 14 "AceEvent-2.0",
14 "AceDB-2.0" 15 "AceDB-2.0"
15 ) 16 )
16
17 local ReAction = ReAction
18 local L = AceLibrary("AceLocale-2.2"):new("ReAction")
19 local AceOO = AceLibrary("AceOO-2.0")
20
21
22 ReAction.revision = tonumber(("$Revision: 1 $"):match("%d+"))
23 ReAction.L = L
24
25 -- global variable strings for integration with WoW keybindings dialog (see bindings.xml) 17 -- global variable strings for integration with WoW keybindings dialog (see bindings.xml)
26 BINDING_HEADER_REACTION = L["ReAction"] 18 BINDING_HEADER_REACTION = L["ReAction"]
27 BINDING_NAME_REACTION_TOGGLELOCK = L["Toggle ReAction Bar Lock"] 19 BINDING_NAME_REACTION_TOGGLELOCK = L["Toggle ReAction Bar Lock"]
28 BINDING_NAME_REACTION_TOGGLEKEYBIND = L["ReAction Keybinding Mode"] 20 BINDING_NAME_REACTION_TOGGLEKEYBIND = L["ReAction Keybinding Mode"]
21
22
23 ------ CORE ------
24 local ReAction = ReAction
25 ReAction.revision = tonumber(("$Revision: 1 $"):match("%d+"))
26 ReAction.L = L
27
28
29 29
30 -- from AceAddon-2.0 30 -- from AceAddon-2.0
31 function ReAction:OnInitialize() 31 function ReAction:OnInitialize()
32 self:RegisterDB("ReActionDB") 32 self:RegisterDB("ReActionDB")
33 end 33 end
98 --seterrorhandler(ReAction.print) 98 --seterrorhandler(ReAction.print)
99 else 99 else
100 ReAction.print = function() end 100 ReAction.print = function() end
101 end 101 end
102 102
103
104 -- utility
105 local newTable, recycle, deepCopy, deepDelete, varName
106 do
107 local pool = setmetatable( { }, {__mode="kv"} )
108
109 function newTable(...)
110 local t = table.remove(pool) or { }
111 for i = 1, select('#',...), 2 do
112 local k = select(i,...)
113 local v = select(i+1,...)
114 if k and v then
115 t[k] = v
116 end
117 end
118 return t
119 end
120
121 function recycle(t)
122 if type(t) == "table" then
123 table.insert(pool,t)
124 end
125 end
126
127 function deepCopy( x )
128 if type(x) ~= "table" then
129 return x
130 end
131 local r = newTable()
132 for k,v in pairs(x) do
133 r[k] = deepCopy(v)
134 end
135 return r
136 end
137
138 function deepDelete( x )
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!
140 for k,v in pairs(x) do
141 x[k] = deepDelete(v)
142 end
143 recycle(x)
144 end
145 end
146
147 function varName(s)
148 return tostring(s):gsub("[^a-zA-Z0-9_]","_")
149 end
150
151 local u = setmetatable( { }, {__newindex = function(self,k,v) rawset(self,#self+1,v) ; rawset(self,k,v) end} )
152 u.deepCopy = deepCopy
153 u.deepDelete = deepDelete
154 u.newTable = newTable
155 u.recycle = recycle
156 u.varName = varName
157
158 ReAction.util = u
159 end
160
161 function ReAction:GetUtilFuncs()
162 return unpack(self.util)
163 end
164