vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- this is a compatibility package. it is recommended |
2 | -- to use the components individually. |
||
3 | |||
4 | local MAJOR_VERSION = "1.0" |
||
5 | local MINOR_VERSION = tonumber(string.sub("$Revision: 1536 $", 12, -3)) |
||
6 | |||
7 | if BabbleLib and BabbleLib.versions[MAJOR_VERSION] and BabbleLib.versions[MAJOR_VERSION].minor >= MINOR_VERSION then |
||
8 | return |
||
9 | end |
||
10 | |||
11 | -------------IRIEL'S-STUB-CODE-------------- |
||
12 | local stub = {}; |
||
13 | |||
14 | -- Instance replacement method, replace contents of old with that of new |
||
15 | function stub:ReplaceInstance(old, new) |
||
16 | for k,v in pairs(old) do old[k]=nil; end |
||
17 | for k,v in pairs(new) do old[k]=v; end |
||
18 | end |
||
19 | |||
20 | -- Get a new copy of the stub |
||
21 | function stub:NewStub() |
||
22 | local newStub = {}; |
||
23 | self:ReplaceInstance(newStub, self); |
||
24 | newStub.lastVersion = ''; |
||
25 | newStub.versions = {}; |
||
26 | return newStub; |
||
27 | end |
||
28 | |||
29 | -- Get instance version |
||
30 | function stub:GetInstance(version) |
||
31 | if (not version) then version = self.lastVersion; end |
||
32 | local versionData = self.versions[version]; |
||
33 | if (not versionData) then |
||
34 | message("Cannot find library instance with version '" |
||
35 | .. version .. "'"); |
||
36 | return; |
||
37 | end |
||
38 | return versionData.instance; |
||
39 | end |
||
40 | |||
41 | -- Register new instance |
||
42 | function stub:Register(newInstance) |
||
43 | local version,minor = newInstance:GetLibraryVersion(); |
||
44 | self.lastVersion = version; |
||
45 | local versionData = self.versions[version]; |
||
46 | if (not versionData) then |
||
47 | -- This one is new! |
||
48 | versionData = { instance = newInstance, |
||
49 | minor = minor, |
||
50 | old = {} |
||
51 | }; |
||
52 | self.versions[version] = versionData; |
||
53 | newInstance:LibActivate(self); |
||
54 | return newInstance; |
||
55 | end |
||
56 | if (minor <= versionData.minor) then |
||
57 | -- This one is already obsolete |
||
58 | if (newInstance.LibDiscard) then |
||
59 | newInstance:LibDiscard(); |
||
60 | end |
||
61 | return versionData.instance; |
||
62 | end |
||
63 | -- This is an update |
||
64 | local oldInstance = versionData.instance; |
||
65 | local oldList = versionData.old; |
||
66 | versionData.instance = newInstance; |
||
67 | versionData.minor = minor; |
||
68 | local skipCopy = newInstance:LibActivate(self, oldInstance, oldList); |
||
69 | table.insert(oldList, oldInstance); |
||
70 | if (not skipCopy) then |
||
71 | for i, old in ipairs(oldList) do |
||
72 | self:ReplaceInstance(old, newInstance); |
||
73 | end |
||
74 | end |
||
75 | return newInstance; |
||
76 | end |
||
77 | |||
78 | -- Bind stub to global scope if it's not already there |
||
79 | if (not BabbleLib) then |
||
80 | BabbleLib = stub:NewStub(); |
||
81 | end |
||
82 | |||
83 | -- Nil stub for garbage collection |
||
84 | stub = nil; |
||
85 | -----------END-IRIEL'S-STUB-CODE------------ |
||
86 | |||
87 | local lib = {} |
||
88 | |||
89 | local core, class, boss, zone, spell, tree |
||
90 | |||
91 | function lib.Deformat(text, a1, a2, a3, a4) |
||
92 | if not core then |
||
93 | core = BabbleLib:GetInstance("Core 1.1") |
||
94 | end |
||
95 | return core:Deformat(text, a1, a2, a3, a4) |
||
96 | end |
||
97 | |||
98 | function lib.GetEnglishClass(alpha) |
||
99 | if not class then |
||
100 | class = BabbleLib:GetInstance("Class 1.1") |
||
101 | end |
||
102 | return class:GetEnglish(alpha) |
||
103 | end |
||
104 | |||
105 | function lib.GetLocalizedClass(alpha) |
||
106 | if not class then |
||
107 | class = BabbleLib:GetInstance("Class 1.1") |
||
108 | end |
||
109 | return class:GetLocalized(alpha) |
||
110 | end |
||
111 | |||
112 | function lib.GetClassIterator() |
||
113 | if not class then |
||
114 | class = BabbleLib:GetInstance("Class 1.1") |
||
115 | end |
||
116 | return class:GetIterator() |
||
117 | end |
||
118 | |||
119 | function lib.GetReverseClassIterator() |
||
120 | if not class then |
||
121 | class = BabbleLib:GetInstance("Class 1.1") |
||
122 | end |
||
123 | return class:GetReverseIterator() |
||
124 | end |
||
125 | |||
126 | function lib.GetClassColor(alpha) |
||
127 | if not class then |
||
128 | class = BabbleLib:GetInstance("Class 1.1") |
||
129 | end |
||
130 | return class:GetColor(alpha) |
||
131 | end |
||
132 | |||
133 | function lib.GetClassHexColor(alpha) |
||
134 | if not class then |
||
135 | class = BabbleLib:GetInstance("Class 1.1") |
||
136 | end |
||
137 | return class:GetHexColor(alpha) |
||
138 | end |
||
139 | |||
140 | function lib.HasClass(alpha) |
||
141 | if not class then |
||
142 | class = BabbleLib:GetInstance("Class 1.1") |
||
143 | end |
||
144 | return class:HasClass(alpha) |
||
145 | end |
||
146 | |||
147 | function lib.GetEnglishBoss(alpha) |
||
148 | if not boss then |
||
149 | boss = BabbleLib:GetInstance("Boss 1.1") |
||
150 | end |
||
151 | return boss:GetEnglish(alpha) |
||
152 | end |
||
153 | |||
154 | function lib.GetLocalizedBoss(alpha) |
||
155 | if not boss then |
||
156 | boss = BabbleLib:GetInstance("Boss 1.1") |
||
157 | end |
||
158 | return boss:GetLocalized(alpha) |
||
159 | end |
||
160 | |||
161 | function lib.GetBossIterator() |
||
162 | if not boss then |
||
163 | boss = BabbleLib:GetInstance("Boss 1.1") |
||
164 | end |
||
165 | return boss:GetIterator() |
||
166 | end |
||
167 | |||
168 | function lib.GetReverseBossIterator() |
||
169 | if not boss then |
||
170 | boss = BabbleLib:GetInstance("Boss 1.1") |
||
171 | end |
||
172 | return boss:GetReverseIterator() |
||
173 | end |
||
174 | |||
175 | function lib.HasBoss(alpha) |
||
176 | if not boss then |
||
177 | boss = BabbleLib:GetInstance("Boss 1.1") |
||
178 | end |
||
179 | return boss:HasBoss(alpha) |
||
180 | end |
||
181 | |||
182 | function lib.GetEnglishZone(alpha) |
||
183 | if not zone then |
||
184 | zone = BabbleLib:GetInstance("Zone 1.1") |
||
185 | end |
||
186 | return zone:GetEnglish(alpha) |
||
187 | end |
||
188 | |||
189 | function lib.GetLocalizedZone(alpha) |
||
190 | if not zone then |
||
191 | zone = BabbleLib:GetInstance("Zone 1.1") |
||
192 | end |
||
193 | return zone:GetLocalized(alpha) |
||
194 | end |
||
195 | |||
196 | function lib.GetZoneIterator() |
||
197 | if not zone then |
||
198 | zone = BabbleLib:GetInstance("Zone 1.1") |
||
199 | end |
||
200 | return zone:GetIterator() |
||
201 | end |
||
202 | |||
203 | function lib.GetReverseZoneIterator() |
||
204 | if not zone then |
||
205 | zone = BabbleLib:GetInstance("Zone 1.1") |
||
206 | end |
||
207 | return zone:GetReverseIterator() |
||
208 | end |
||
209 | |||
210 | function lib.HasZone(alpha) |
||
211 | if not zone then |
||
212 | zone = BabbleLib:GetInstance("Zone 1.1") |
||
213 | end |
||
214 | return zone:HasZone(alpha) |
||
215 | end |
||
216 | |||
217 | function lib.GetEnglishSpell(alpha) |
||
218 | if not spell then |
||
219 | spell = BabbleLib:GetInstance("Spell 1.1") |
||
220 | end |
||
221 | return spell:GetEnglish(alpha) |
||
222 | end |
||
223 | |||
224 | function lib.GetLocalizedSpell(alpha) |
||
225 | if not spell then |
||
226 | spell = BabbleLib:GetInstance("Spell 1.1") |
||
227 | end |
||
228 | return spell:GetLocalized(alpha) |
||
229 | end |
||
230 | |||
231 | function lib.GetSpellIterator() |
||
232 | if not spell then |
||
233 | spell = BabbleLib:GetInstance("Spell 1.1") |
||
234 | end |
||
235 | return spell:GetIterator() |
||
236 | end |
||
237 | |||
238 | function lib.GetReverseSpellIterator() |
||
239 | if not spell then |
||
240 | spell = BabbleLib:GetInstance("Spell 1.1") |
||
241 | end |
||
242 | return spell:GetReverseIterator() |
||
243 | end |
||
244 | |||
245 | function lib.HasSpell(alpha) |
||
246 | if not spell then |
||
247 | spell = BabbleLib:GetInstance("Spell 1.1") |
||
248 | end |
||
249 | return spell:HasSpell(alpha) |
||
250 | end |
||
251 | |||
252 | function lib.GetSpellIcon(alpha) |
||
253 | if not spell then |
||
254 | spell = BabbleLib:GetInstance("Spell 1.1") |
||
255 | end |
||
256 | return spell:GetSpellIcon(alpha) |
||
257 | end |
||
258 | |||
259 | function lib.GetEnglishSpellTree(alpha) |
||
260 | if not tree then |
||
261 | tree = BabbleLib:GetInstance("SpellTree 1.1") |
||
262 | end |
||
263 | return tree:GetEnglish(alpha) |
||
264 | end |
||
265 | |||
266 | function lib.GetLocalizedSpellTree(alpha) |
||
267 | if not tree then |
||
268 | tree = BabbleLib:GetInstance("SpellTree 1.1") |
||
269 | end |
||
270 | return tree:GetLocalized(alpha) |
||
271 | end |
||
272 | |||
273 | function lib.GetSpellTreeIterator() |
||
274 | if not tree then |
||
275 | tree = BabbleLib:GetInstance("SpellTree 1.1") |
||
276 | end |
||
277 | return tree:GetIterator() |
||
278 | end |
||
279 | |||
280 | function lib.GetReverseSpellTreeIterator() |
||
281 | if not tree then |
||
282 | tree = BabbleLib:GetInstance("SpellTree 1.1") |
||
283 | end |
||
284 | return tree:GetReverseIterator() |
||
285 | end |
||
286 | |||
287 | function lib.HasSpellTree(alpha) |
||
288 | if not tree then |
||
289 | tree = BabbleLib:GetInstance("SpellTree 1.1") |
||
290 | end |
||
291 | return tree:HasSpellTree(alpha) |
||
292 | end |
||
293 | |||
294 | function lib:GetLibraryVersion() |
||
295 | return MAJOR_VERSION, MINOR_VERSION |
||
296 | end |
||
297 | |||
298 | function lib:LibActivate(stub, oldLib, oldList) |
||
299 | end |
||
300 | |||
301 | function lib:LibDeactivate() |
||
302 | end |
||
303 | |||
304 | BabbleLib:Register(lib) |
||
305 | lib = nil |