vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local Default = { |
2 | CastingBar = { |
||
3 | width = 255, |
||
4 | height = 25, |
||
5 | edgeFile = "Default", |
||
6 | texture = "Default", |
||
7 | timeSize = 12, |
||
8 | spellSize = 10, |
||
9 | delaySize = 14, |
||
10 | }, |
||
11 | MirrorBar = { |
||
12 | width = 255, |
||
13 | height = 25, |
||
14 | edgeFile = "Default", |
||
15 | texture = "Default", |
||
16 | timeSize = 12, |
||
17 | spellSize = 10, |
||
18 | delaySize = 14, |
||
19 | }, |
||
20 | Colors = { |
||
21 | Complete = {r=0, g=1, b=0}, |
||
22 | Casting = {r=1, g=.7, b=0}, |
||
23 | Channel = {r=.3, g=.3, b=1}, |
||
24 | Failed = {r=1, g=0, b=0}, |
||
25 | }, |
||
26 | Mirror = { |
||
27 | EXHAUSTION = {r=1, g=.9, b=0}, |
||
28 | BREATH = {r=0, g=.5, b=1}, |
||
29 | DEATH = {r=0, g=.7, b=1}, |
||
30 | FEIGNDEATH = {r=1, g=.7, b=1} |
||
31 | }, |
||
32 | Pos = {} |
||
33 | } |
||
34 | local Textures = { |
||
35 | ["Default"] = "Interface\\AddOns\\oCB\\textures\\oCB", |
||
36 | ["Perl"] = "Interface\\AddOns\\oCB\\textures\\perl", |
||
37 | ["Smooth"] = "Interface\\AddOns\\oCB\\textures\\smooth", |
||
38 | ["Glaze"] = "Interface\\AddOns\\oCB\\textures\\glaze", |
||
39 | ["Blizzard"] = "Interface\\TargetingFrame\\UI-StatusBar", |
||
40 | ["Striped"] = "Interface\\AddOns\\oCB\\textures\\striped", |
||
41 | ["BantoBar"] = "Interface\\AddOns\\oCB\\textures\\BantoBar", |
||
42 | } |
||
43 | local Borders = { |
||
44 | ["Default"] = "Interface\\Tooltips\\UI-Tooltip-Border", |
||
45 | ["None"] = "" |
||
46 | } |
||
47 | |||
48 | oCB = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceDebug-2.0", "AceHook-2.0", "AceDB-2.0", "AceConsole-2.0") |
||
49 | |||
50 | function oCB:OnInitialize() |
||
51 | self.Textures = Textures |
||
52 | self.Borders = Borders |
||
53 | |||
54 | local consoleOptions = { |
||
55 | type = 'group', |
||
56 | args = { |
||
57 | lock = { |
||
58 | name = "Lock", type = 'toggle', order = 1, |
||
59 | desc = "Lock/Unlock the casting bar.", |
||
60 | get = function() return self.db.profile.lock end, |
||
61 | set = function() self.db.profile.lock = not self.db.profile.lock end |
||
62 | }, |
||
63 | castingbar = { |
||
64 | name = "Casting Bar", type = 'group', order = 2, |
||
65 | desc = "Casting Bar", |
||
66 | args = { |
||
67 | width = { |
||
68 | name = "Width", type = 'range', min = 10, max = 500, step = 1, |
||
69 | desc = "Set the width of the casting bar.", |
||
70 | get = function() return self.db.profile.CastingBar.width end, |
||
71 | set = function(v) |
||
72 | self.db.profile.CastingBar.width = v |
||
73 | self:Layout("CastingBar") |
||
74 | end |
||
75 | }, |
||
76 | height = { |
||
77 | name = "Height", type = 'range', min = 5, max = 50, step = 1, |
||
78 | desc = "Set the height of the casting bar.", |
||
79 | get = function() return self.db.profile.CastingBar.height end, |
||
80 | set = function(v) |
||
81 | self.db.profile.CastingBar.height = v |
||
82 | self:Layout("CastingBar") |
||
83 | end |
||
84 | }, |
||
85 | border = { |
||
86 | name = "Border", type = 'text', |
||
87 | desc = "Toggle the border.", |
||
88 | get = function() return self.db.profile.CastingBar.edgeFile end, |
||
89 | set = function(v) |
||
90 | self.db.profile.CastingBar.edgeFile = v |
||
91 | self:Layout("CastingBar") |
||
92 | end, |
||
93 | validate = {"Default","None"} |
||
94 | }, |
||
95 | texture = { |
||
96 | name = "Texture", type = 'text', |
||
97 | desc = "Toggle the texture.", |
||
98 | get = function() return self.db.profile.CastingBar.texture end, |
||
99 | set = function(v) |
||
100 | self.db.profile.CastingBar.texture = v |
||
101 | self:Layout("CastingBar") |
||
102 | end, |
||
103 | validate = {"Default","Perl","Smooth","Glaze","Blizzard","Striped", "BantoBar"} |
||
104 | }, |
||
105 | font = { |
||
106 | name = "Font", type = 'group', |
||
107 | desc = "Set the font size of different elements.", |
||
108 | args = { |
||
109 | spell = { |
||
110 | name = "Spell", type = 'range', min = 6, max = 32, step = 1, |
||
111 | desc = "Set the font size on the spellname, when casting.", |
||
112 | get = function() return self.db.profile.CastingBar.spellSize end, |
||
113 | set = function(v) |
||
114 | self.db.profile.CastingBar.spellSize = v |
||
115 | self:Layout("CastingBar") |
||
116 | end |
||
117 | }, |
||
118 | time = { |
||
119 | name = "Time", type = 'range', min = 6, max = 32, step = 1, |
||
120 | desc = "Set the font size on the spell time.", |
||
121 | get = function() return self.db.profile.CastingBar.timeSize end, |
||
122 | set = function(v) |
||
123 | self.db.profile.CastingBar.timeSize = v |
||
124 | self:Layout("CastingBar") |
||
125 | end |
||
126 | }, |
||
127 | delay = { |
||
128 | name = "Delay", type = 'range', min = 6, max = 32, step = 1, |
||
129 | desc = "Set the font size on the delay time.", |
||
130 | get = function() return self.db.profile.CastingBar.delaySize end, |
||
131 | set = function(v) |
||
132 | self.db.profile.CastingBar.delaySize = v |
||
133 | self:Layout("CastingBar") |
||
134 | end |
||
135 | } |
||
136 | } |
||
137 | } |
||
138 | } |
||
139 | }, |
||
140 | mirrorbar = { |
||
141 | name = "Mirror Bar", type = 'group', order = 3, |
||
142 | desc = "Mirror Bar", |
||
143 | args = { |
||
144 | width = { |
||
145 | name = "Width", type = 'range', min = 10, max = 500, step = 1, |
||
146 | desc = "Set the width of the mirror bar.", |
||
147 | get = function() return self.db.profile.MirrorBar.width end, |
||
148 | set = function(v) |
||
149 | self.db.profile.MirrorBar.width = v |
||
150 | self:Layout("BREATH", "MirrorBar") |
||
151 | self:Layout("EXHAUSTION", "MirrorBar") |
||
152 | self:Layout("FEIGNDEATH", "MirrorBar") |
||
153 | end |
||
154 | }, |
||
155 | height = { |
||
156 | name = "Height", type = 'range', min = 5, max = 50, step = 1, |
||
157 | desc = "Set the height of the mirror bar.", |
||
158 | get = function() return self.db.profile.MirrorBar.height end, |
||
159 | set = function(v) |
||
160 | self.db.profile.MirrorBar.height = v |
||
161 | self:Layout("BREATH", "MirrorBar") |
||
162 | self:Layout("EXHAUSTION", "MirrorBar") |
||
163 | self:Layout("FEIGNDEATH", "MirrorBar") |
||
164 | end |
||
165 | }, |
||
166 | border = { |
||
167 | name = "Border", type = 'text', |
||
168 | desc = "Toggle the border.", |
||
169 | get = function() return self.db.profile.MirrorBar.edgeFile end, |
||
170 | set = function(v) |
||
171 | self.db.profile.MirrorBar.edgeFile = v |
||
172 | self:Layout("BREATH", "MirrorBar") |
||
173 | self:Layout("EXHAUSTION", "MirrorBar") |
||
174 | self:Layout("FEIGNDEATH", "MirrorBar") |
||
175 | end, |
||
176 | validate = {"Default","None"} |
||
177 | }, |
||
178 | texture = { |
||
179 | name = "Texture", type = 'text', |
||
180 | desc = "Toggle the texture.", |
||
181 | get = function() return self.db.profile.MirrorBar.texture end, |
||
182 | set = function(v) |
||
183 | self.db.profile.MirrorBar.texture = v |
||
184 | self:Layout("BREATH", "MirrorBar") |
||
185 | self:Layout("EXHAUSTION", "MirrorBar") |
||
186 | self:Layout("FEIGNDEATH", "MirrorBar") |
||
187 | end, |
||
188 | validate = {"Default","Perl","Smooth","Glaze","Blizzard","Striped", "BantoBar"} |
||
189 | }, |
||
190 | font = { |
||
191 | name = "Font", type = 'group', |
||
192 | desc = "Set the font size of different elements.", |
||
193 | args = { |
||
194 | spell = { |
||
195 | name = "Spell", type = 'range', min = 6, max = 32, step = 1, |
||
196 | desc = "Set the font size on the spellname, when shown.", |
||
197 | get = function() return self.db.profile.MirrorBar.spellSize end, |
||
198 | set = function(v) |
||
199 | self.db.profile.MirrorBar.spellSize = v |
||
200 | self:Layout("MirrorBar") |
||
201 | end |
||
202 | }, |
||
203 | time = { |
||
204 | name = "Time", type = 'range', min = 6, max = 32, step = 1, |
||
205 | desc = "Set the font size on the spell time.", |
||
206 | get = function() return self.db.profile.MirrorBar.timeSize end, |
||
207 | set = function(v) |
||
208 | self.db.profile.MirrorBar.timeSize = v |
||
209 | self:Layout("BREATH", "MirrorBar") |
||
210 | self:Layout("EXHAUSTION", "MirrorBar") |
||
211 | self:Layout("FEIGNDEATH", "MirrorBar") |
||
212 | end |
||
213 | }, |
||
214 | delay = { |
||
215 | name = "Delay", type = 'range', min = 6, max = 32, step = 1, |
||
216 | desc = "Set the font size on the delay time.", |
||
217 | get = function() return self.db.profile.MirrorBar.delaySize end, |
||
218 | set = function(v) |
||
219 | self.db.profile.MirrorBar.delaySize = v |
||
220 | self:Layout("BREATH", "MirrorBar") |
||
221 | self:Layout("EXHAUSTION", "MirrorBar") |
||
222 | self:Layout("FEIGNDEATH", "MirrorBar") |
||
223 | end |
||
224 | } |
||
225 | } |
||
226 | } |
||
227 | } |
||
228 | }, |
||
229 | colors = { |
||
230 | name = "Colors", type = 'group', order = 4, |
||
231 | desc = "Set the bar colors.", |
||
232 | args = { |
||
233 | spell = { |
||
234 | name = "Spell", type = 'color', |
||
235 | desc = "Sets the color of the casting bars on spells.", |
||
236 | get = function() |
||
237 | local v = self.db.profile.Colors.Casting |
||
238 | return v.r,v.g,v.b |
||
239 | end, |
||
240 | set = function(r,g,b) self.db.profile.Colors.Casting = {r=r,g=g,b=b} end |
||
241 | }, |
||
242 | success = { |
||
243 | name = "Success", type = 'color', |
||
244 | desc = "Sets the color of the casting bars on succsessful casts.", |
||
245 | get = function() |
||
246 | local v = self.db.profile.Colors.Complete |
||
247 | return v.r,v.g,v.b |
||
248 | end, |
||
249 | set = function(r,g,b) self.db.profile.Colors.Complete = {r=r,g=g,b=b} end |
||
250 | }, |
||
251 | channel = { |
||
252 | name = "Channel", type = 'color', |
||
253 | desc = "Sets the color of the casting bars while channeling.", |
||
254 | get = function() |
||
255 | local v = self.db.profile.Colors.Channel |
||
256 | return v.r,v.g,v.b |
||
257 | end, |
||
258 | set = function(r,g,b) self.db.profile.Colors.Channel = {r=r,g=g,b=b} end |
||
259 | }, |
||
260 | failed = { |
||
261 | name = "Failed", type = 'color', |
||
262 | desc = "Sets the color of the casting bars on failed casts.", |
||
263 | get = function() |
||
264 | local v = self.db.profile.Colors.Failed |
||
265 | return v.r,v.g,v.b |
||
266 | end, |
||
267 | set = function(r,g,b) self.db.profile.Colors.Failed = {r=r,g=g,b=b} end |
||
268 | } |
||
269 | } |
||
270 | } |
||
271 | } |
||
272 | } |
||
273 | |||
274 | self:RegisterDB("oCBDB") |
||
275 | self:RegisterDefaults('profile', Default) |
||
276 | |||
277 | self:RegisterChatCommand({ "/oCB"}, consoleOptions) |
||
278 | |||
279 | self:SetDebugging(false) |
||
280 | end |
||
281 | |||
282 | function oCB:OnEnable() |
||
283 | if not self.frames then self.frames = {} end |
||
284 | |||
285 | self:Events() |
||
286 | self:HideBlizzCB() |
||
287 | |||
288 | self:CreateFramework("CastingBar", "oCBFrame") |
||
289 | self:CreateFramework("BREATH", "oCBMirror1", "MirrorBar") |
||
290 | self:CreateFramework("EXHAUSTION","oCBMirror2", "MirrorBar") |
||
291 | self:CreateFramework("FEIGNDEATH","oCBMirror3", "MirrorBar") |
||
292 | end |
||
293 | |||
294 | function oCB:Events() |
||
295 | self:RegisterEvent("SPELLCAST_START", "SpellStart") |
||
296 | self:RegisterEvent("SPELLCAST_CHANNEL_START", "SpellChannelStart") |
||
297 | self:RegisterEvent("SPELLCAST_CHANNEL_STOP", "SpellChannelStop") |
||
298 | self:RegisterEvent("SPELLCAST_CHANNEL_UPDATE", "SpellChannelUpdate") |
||
299 | |||
300 | self:RegisterEvent("MIRROR_TIMER_START") |
||
301 | self:RegisterEvent("MIRROR_TIMER_PAUSE") |
||
302 | self:RegisterEvent("MIRROR_TIMER_STOP") |
||
303 | |||
304 | UIParent:UnregisterEvent("MIRROR_TIMER_START") |
||
305 | end |
||
306 | |||
307 | function oCB:updatePositions(n) |
||
308 | if(self.db.profile.Pos[n]) then |
||
309 | local z = self:Split(self.db.profile.Pos[n], " ") |
||
310 | local s = self.frames[n]:GetEffectiveScale() |
||
311 | |||
312 | self.frames[n]:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", z[1]/s, z[2]/s) |
||
313 | elseif(self.frames[n]) then |
||
314 | self.frames[n]:ClearAllPoints() |
||
315 | self.frames[n]:SetPoint("CENTER", UIParent, "CENTER", 0, 0) |
||
316 | end |
||
317 | end |
||
318 | |||
319 | function oCB:savePosition() |
||
320 | local f = self.frames[this.name] |
||
321 | local x,y = f:GetLeft(), f:GetTop() |
||
322 | local s = f:GetEffectiveScale() |
||
323 | |||
324 | x,y = x*s,y*s |
||
325 | |||
326 | self.db.profile.Pos[this.name] = x.." "..y |
||
327 | end |
||
328 | |||
329 | function oCB:Split(msg, char) |
||
330 | local arr = { }; |
||
331 | while (string.find(msg, char) ) do |
||
332 | local iStart, iEnd = string.find(msg, char); |
||
333 | tinsert(arr, strsub(msg, 1, iStart-1)); |
||
334 | msg = strsub(msg, iEnd+1, strlen(msg)); |
||
335 | end |
||
336 | if ( strlen(msg) > 0 ) then |
||
337 | tinsert(arr, msg); |
||
338 | end |
||
339 | return arr; |
||
340 | end |