vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function DUF_Element_OnClick(button) |
2 | if (this.moving) then |
||
3 | DUF_Element_OnDragStop(); |
||
4 | end |
||
5 | |||
6 | local unit = this.unit; |
||
7 | if (not unit) then |
||
8 | unit = this:GetParent().unit; |
||
9 | end |
||
10 | |||
11 | if ( SpellIsTargeting() ) then |
||
12 | if (button == "RightButton") then |
||
13 | SpellStopTargeting(); |
||
14 | else |
||
15 | SpellTargetUnit(unit); |
||
16 | end |
||
17 | return; |
||
18 | elseif (CursorHasItem()) then |
||
19 | DropItemOnUnit(unit); |
||
20 | return; |
||
21 | end |
||
22 | |||
23 | local frameindex = DUF_FRAME_DATA[unit].index |
||
24 | local action; |
||
25 | if (button == "LeftButton") then |
||
26 | if (this.subindex) then |
||
27 | action = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].leftclick; |
||
28 | else |
||
29 | action = DUF_Settings[DUF_INDEX][frameindex][this.index].leftclick; |
||
30 | end |
||
31 | elseif (button == "RightButton") then |
||
32 | if (this.subindex) then |
||
33 | action = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].rightclick; |
||
34 | else |
||
35 | action = DUF_Settings[DUF_INDEX][frameindex][this.index].rightclick; |
||
36 | end |
||
37 | elseif (button == "MiddleButton") then |
||
38 | if (this.subindex) then |
||
39 | action = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].middleclick; |
||
40 | else |
||
41 | action = DUF_Settings[DUF_INDEX][frameindex][this.index].middleclick; |
||
42 | end |
||
43 | end |
||
44 | if (action == 1) then |
||
45 | TargetUnit(unit); |
||
46 | elseif (action == 2) then |
||
47 | AssistUnit(unit); |
||
48 | elseif (action == 3) then |
||
49 | DUF_UnitPopup_ShowMenu(unit); |
||
50 | end |
||
51 | end |
||
52 | |||
53 | function DUF_Element_OnDragStart() |
||
54 | if (DUF_ELEMENTS_UNLOCKED) then |
||
55 | this.moving = true; |
||
56 | if (this.moveparent) then |
||
57 | this:GetParent():StartMoving(); |
||
58 | else |
||
59 | this:StartMoving(); |
||
60 | end |
||
61 | elseif (DUF_FRAMES_UNLOCKED) then |
||
62 | if (this.moveparent) then |
||
63 | this:GetParent():GetParent():StartMoving(); |
||
64 | else |
||
65 | this:GetParent():StartMoving(); |
||
66 | end |
||
67 | end |
||
68 | end |
||
69 | |||
70 | function DUF_Element_GetOffsets(element, baseframe, settings) |
||
71 | if (settings.attach ~= "Unit Frame" and settings.attach ~= "UIParent") then |
||
72 | baseframe = getglobal(baseframe:GetName()..settings.attach); |
||
73 | elseif (settings.attach == "UIParent") then |
||
74 | baseframe = UIParent; |
||
75 | end |
||
76 | local xoffset, yoffset = DL_Get_Offsets(element, baseframe, settings.attachpoint, settings.attachto) |
||
77 | return xoffset, yoffset; |
||
78 | end |
||
79 | |||
80 | function DUF_Element_OnDragStop() |
||
81 | if (DUF_ELEMENTS_UNLOCKED) then |
||
82 | this.moving = nil; |
||
83 | if (this.moveparent) then |
||
84 | this:GetParent():StopMovingOrSizing(); |
||
85 | else |
||
86 | this:StopMovingOrSizing(); |
||
87 | end |
||
88 | local frameindex, unitframe, xoffset, yoffset, settings; |
||
89 | if (this.moveparent) then |
||
90 | frameindex = DUF_FRAME_DATA[this:GetParent():GetParent().unit].index; |
||
91 | if (this:GetParent().subindex) then |
||
92 | settings = DUF_Settings[DUF_INDEX][frameindex][this:GetParent().index][this:GetParent().subindex]; |
||
93 | else |
||
94 | settings = DUF_Settings[DUF_INDEX][frameindex][this:GetParent().index]; |
||
95 | end |
||
96 | unitframe = getglobal(this:GetParent():GetParent():GetName()); |
||
97 | xoffset, yoffset = DUF_Element_GetOffsets(this:GetParent(), unitframe, settings); |
||
98 | else |
||
99 | frameindex = DUF_FRAME_DATA[this:GetParent().unit].index; |
||
100 | if (this.subindex) then |
||
101 | settings = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex]; |
||
102 | else |
||
103 | settings = DUF_Settings[DUF_INDEX][frameindex][this.index]; |
||
104 | end |
||
105 | unitframe = getglobal(this:GetParent():GetName()); |
||
106 | xoffset, yoffset = DUF_Element_GetOffsets(this, unitframe, settings); |
||
107 | end |
||
108 | if (this.subindex) then |
||
109 | DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].xoffset = xoffset; |
||
110 | DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].yoffset = yoffset; |
||
111 | elseif (this.moveparent) then |
||
112 | DUF_Settings[DUF_INDEX][frameindex][this:GetParent().index].xoffset = xoffset; |
||
113 | DUF_Settings[DUF_INDEX][frameindex][this:GetParent().index].yoffset = yoffset; |
||
114 | else |
||
115 | DUF_Settings[DUF_INDEX][frameindex][this.index].xoffset = xoffset; |
||
116 | DUF_Settings[DUF_INDEX][frameindex][this.index].yoffset = yoffset; |
||
117 | end |
||
118 | if (this.moveparent) then |
||
119 | local settings = DUF_Settings[DUF_INDEX][frameindex][this:GetParent().index]; |
||
120 | local element = DUF_Get_ElementName(this:GetParent().index, this:GetParent().subindex); |
||
121 | if (frameindex == "party" or frameindex == "partypet") then |
||
122 | for i=1,4 do |
||
123 | local unitFrame = DUF_FRAME_DATA[frameindex..i].frame; |
||
124 | DUF_Set_ElementPosition(getglobal(unitFrame..element), unitFrame, settings); |
||
125 | end |
||
126 | else |
||
127 | local unitFrame = DUF_FRAME_DATA[frameindex].frame; |
||
128 | DUF_Set_ElementPosition(getglobal(unitFrame..element), unitFrame, settings); |
||
129 | end |
||
130 | else |
||
131 | local settings; |
||
132 | if (this.subindex) then |
||
133 | settings = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex]; |
||
134 | else |
||
135 | settings = DUF_Settings[DUF_INDEX][frameindex][this.index]; |
||
136 | end |
||
137 | local element = DUF_Get_ElementName(this.index, this.subindex); |
||
138 | if (frameindex == "party" or frameindex == "partypet") then |
||
139 | for i=1,4 do |
||
140 | local unitFrame = DUF_FRAME_DATA[frameindex..i].frame; |
||
141 | DUF_Set_ElementPosition(getglobal(unitFrame..element), unitFrame, settings); |
||
142 | end |
||
143 | else |
||
144 | local unitFrame = DUF_FRAME_DATA[frameindex].frame; |
||
145 | DUF_Set_ElementPosition(getglobal(unitFrame..element), unitFrame, settings); |
||
146 | end |
||
147 | end |
||
148 | if (DUF_Options) then |
||
149 | DUF_Init_BaseOptions(); |
||
150 | end |
||
151 | elseif (DUF_FRAMES_UNLOCKED) then |
||
152 | if (this.moveparent) then |
||
153 | this = this:GetParent():GetParent(); |
||
154 | else |
||
155 | this = this:GetParent(); |
||
156 | end |
||
157 | DUF_UnitFrame_OnDragStop(); |
||
158 | end |
||
159 | end |
||
160 | |||
161 | function DUF_Element_OnEnter() |
||
162 | local unit = this:GetParent().unit; |
||
163 | local settings; |
||
164 | if (this.subindex) then |
||
165 | settings = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index][this.index][this.subindex]; |
||
166 | else |
||
167 | settings = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index][this.index]; |
||
168 | end |
||
169 | |||
170 | if (settings.usemouseovercolor) then |
||
171 | getglobal(this:GetName().."_Background"):SetBackdropColor(settings.mouseovercolor.r, settings.mouseovercolor.g, settings.mouseovercolor.b, settings.bgalpha); |
||
172 | end |
||
173 | |||
174 | if (settings.mouseovergroup) then |
||
175 | local unitFrame = this:GetParent(); |
||
176 | local unitFrameName = unitFrame:GetName(); |
||
177 | local element; |
||
178 | |||
179 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].mouseovergroup == settings.mouseovergroup) then |
||
180 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].usemouseovercolor) then |
||
181 | getglobal(this:GetParent():GetName().."_Background"):SetBackdropColor(DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].mouseovercolor.r, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].mouseovercolor.g, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].mouseovercolor.b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].bgalpha); |
||
182 | end |
||
183 | end |
||
184 | |||
185 | for index, value in DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index] do |
||
186 | if (type(value) == "table") then |
||
187 | if (index == "StatusBar") then |
||
188 | for i = 1,6 do |
||
189 | if (value[i]) then |
||
190 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
191 | if (value[i].mouseover) then |
||
192 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Show(); |
||
193 | elseif (value[i].hidemouseover) then |
||
194 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):SetAlpha(0); |
||
195 | end |
||
196 | if (value[i].usemouseovercolor) then |
||
197 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].mouseovercolor.r, value[i].mouseovercolor.g, value[i].mouseovercolor.b, value[i].bgalpha); |
||
198 | end |
||
199 | end |
||
200 | end |
||
201 | end |
||
202 | elseif (index == "TextBox") then |
||
203 | for i = 1,10 do |
||
204 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
205 | if (value[i].mouseover) then |
||
206 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Show(); |
||
207 | elseif (value[i].hidemouseover) then |
||
208 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):SetAlpha(0); |
||
209 | end |
||
210 | if (value[i].usemouseovercolor) then |
||
211 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].mouseovercolor.r, value[i].mouseovercolor.g, value[i].mouseovercolor.b, value[i].bgalpha); |
||
212 | end |
||
213 | end |
||
214 | end |
||
215 | else |
||
216 | if (value.mouseovergroup == settings.mouseovergroup) then |
||
217 | if (value.mouseover) then |
||
218 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Show(); |
||
219 | elseif (value.hidemouseover) then |
||
220 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):SetAlpha(0); |
||
221 | end |
||
222 | if (value.usemouseovercolor) then |
||
223 | getglobal(unitFrameName..DUF_Get_ElementName(index).."_Background"):SetBackdropColor(value.mouseovercolor.r, value.mouseovercolor.g, value.mouseovercolor.b, value.bgalpha); |
||
224 | end |
||
225 | end |
||
226 | end |
||
227 | end |
||
228 | end |
||
229 | end |
||
230 | |||
231 | if (settings.hidemouseover) then |
||
232 | this.oldalpha = this:GetAlpha(); |
||
233 | this:SetAlpha(0); |
||
234 | end |
||
235 | |||
236 | if (settings.disabletooltip) then |
||
237 | return; |
||
238 | end |
||
239 | if (unit and UnitName(unit)) then |
||
240 | if (settings.usecustomtooltip) then |
||
241 | local text = settings.customtooltip; |
||
242 | if (text) then |
||
243 | for var, value in DUF_VARIABLE_FUNCTIONS do |
||
244 | if (string.find(text, var)) then |
||
245 | text = value.func(text, unit); |
||
246 | end |
||
247 | end |
||
248 | GameTooltip_SetDefaultAnchor(GameTooltip, this) |
||
249 | GameTooltip:SetText(text, 1, 1, 1, 1, 1); |
||
250 | GameTooltip:Show(); |
||
251 | end |
||
252 | else |
||
253 | this.unit = unit; |
||
254 | UnitFrame_OnEnter(); |
||
255 | end |
||
256 | end |
||
257 | end |
||
258 | |||
259 | function DUF_Element_OnEvent(event) |
||
260 | |||
261 | end |
||
262 | |||
263 | function DUF_Element_OnHide() |
||
264 | if (this.moving) then |
||
265 | DUF_Element_OnDragStop(); |
||
266 | end |
||
267 | end |
||
268 | |||
269 | function DUF_Element_OnLeave() |
||
270 | if (this:GetParent().unit and UnitName(this:GetParent().unit)) then |
||
271 | this.unit = this:GetParent().unit; |
||
272 | UnitFrame_OnLeave(); |
||
273 | end |
||
274 | |||
275 | if (this.moving) then |
||
276 | DUF_Element_OnDragStop(); |
||
277 | end |
||
278 | |||
279 | local unit = this:GetParent().unit; |
||
280 | |||
281 | local settings; |
||
282 | if (this.subindex) then |
||
283 | settings = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index][this.index][this.subindex]; |
||
284 | else |
||
285 | settings = DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index][this.index]; |
||
286 | end |
||
287 | |||
288 | if (this.oldalpha) then |
||
289 | this:SetAlpha(this.oldalpha); |
||
290 | this.oldalpha = nil; |
||
291 | end |
||
292 | |||
293 | if (settings.usemouseovercolor) then |
||
294 | getglobal(this:GetName().."_Background"):SetBackdropColor(settings.bgcolor.r, settings.bgcolor.g, settings.bgcolor.b, settings.bgalpha); |
||
295 | end |
||
296 | |||
297 | if (settings.mouseovergroup) then |
||
298 | local unitFrame = this:GetParent(); |
||
299 | local unitFrameName = unitFrame:GetName(); |
||
300 | local element; |
||
301 | |||
302 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].mouseovergroup == settings.mouseovergroup) then |
||
303 | if (DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].usemouseovercolor) then |
||
304 | getglobal(this:GetParent():GetName().."_Background"):SetBackdropColor(DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].bgcolor.r, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].bgcolor.g, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].bgcolor.b, DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index].bgalpha); |
||
305 | end |
||
306 | end |
||
307 | |||
308 | for index, value in DUF_Settings[DUF_INDEX][DUF_FRAME_DATA[unit].index] do |
||
309 | if (type(value) == "table") then |
||
310 | if (index == "StatusBar") then |
||
311 | for i = 1,6 do |
||
312 | if (value[i]) then |
||
313 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
314 | if (value[i].mouseover) then |
||
315 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Hide(); |
||
316 | elseif (value[i].hidemouseover) then |
||
317 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):SetAlpha(value[i].alpha); |
||
318 | end |
||
319 | if (value[i].usemouseovercolor) then |
||
320 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].bgcolor.r, value[i].bgcolor.g, value[i].bgcolor.b, value[i].bgalpha); |
||
321 | end |
||
322 | end |
||
323 | end |
||
324 | end |
||
325 | elseif (index == "TextBox") then |
||
326 | for i = 1,10 do |
||
327 | if (value[i].mouseovergroup == settings.mouseovergroup) then |
||
328 | if (value[i].mouseover) then |
||
329 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Hide(); |
||
330 | elseif (value[i].hidemouseover) then |
||
331 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):SetAlpha(value[i].alpha); |
||
332 | end |
||
333 | if (value[i].usemouseovercolor) then |
||
334 | getglobal(unitFrameName..DUF_Get_ElementName(index, i).."_Background"):SetBackdropColor(value[i].bgcolor.r, value[i].bgcolor.g, value[i].bgcolor.b, value[i].bgalpha); |
||
335 | end |
||
336 | end |
||
337 | end |
||
338 | else |
||
339 | if (value.mouseovergroup == settings.mouseovergroup) then |
||
340 | if (value.mouseover) then |
||
341 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):Hide(); |
||
342 | elseif (value.hidemouseover) then |
||
343 | getglobal(unitFrameName..DUF_Get_ElementName(index, i)):SetAlpha(value.alpha); |
||
344 | end |
||
345 | if (value.usemouseovercolor) then |
||
346 | getglobal(unitFrameName..DUF_Get_ElementName(index).."_Background"):SetBackdropColor(value.bgcolor.r, value.bgcolor.g, value.bgcolor.b, value.bgalpha); |
||
347 | end |
||
348 | end |
||
349 | end |
||
350 | end |
||
351 | end |
||
352 | end |
||
353 | end |
||
354 | |||
355 | function DUF_Element_OnLoad() |
||
356 | this:RegisterForDrag("LeftButton", "RightButton"); |
||
357 | this:RegisterForClicks("LeftButtonUp", "RightButtonUp", "MiddleButtonUp", "Button4Up", "Button5Up"); |
||
358 | if (string.find(this:GetName(), "Bar")) then |
||
359 | this.index = "StatusBar"; |
||
360 | this.subindex = this:GetID(); |
||
361 | elseif (string.find(this:GetName(), "Portrait")) then |
||
362 | this.index = "Portrait"; |
||
363 | elseif (string.find(this:GetName(), "ClassIcon")) then |
||
364 | this.index = "ClassIcon"; |
||
365 | elseif (string.find(this:GetName(), "RankIcon")) then |
||
366 | this.index = "RankIcon"; |
||
367 | elseif (string.find(this:GetName(), "RaceIcon")) then |
||
368 | this.index = "RaceIcon"; |
||
369 | elseif (string.find(this:GetName(), "Buffs")) then |
||
370 | this.index = "Buffs"; |
||
371 | elseif (string.find(this:GetName(), "Debuffs")) then |
||
372 | this.index = "Debuffs"; |
||
373 | elseif (string.find(this:GetName(), "LootIcon")) then |
||
374 | this.index = "LootIcon"; |
||
375 | elseif (string.find(this:GetName(), "PVPIcon")) then |
||
376 | this.index = "PVPIcon"; |
||
377 | elseif (string.find(this:GetName(), "LeaderIcon")) then |
||
378 | this.index = "LeaderIcon"; |
||
379 | elseif (string.find(this:GetName(), "StatusIcon")) then |
||
380 | this.index = "StatusIcon"; |
||
381 | elseif (string.find(this:GetName(), "TextBox")) then |
||
382 | this.index = "TextBox"; |
||
383 | this.subindex = this:GetID(); |
||
384 | elseif (string.find(this:GetName(), "HappinessIcon")) then |
||
385 | this.index = "HappinessIcon"; |
||
386 | elseif (string.find(this:GetName(), "ComboPoints")) then |
||
387 | this.index = "ComboPoints"; |
||
388 | elseif (string.find(this:GetName(), "EliteTexture")) then |
||
389 | this.index = "EliteTexture"; |
||
390 | end |
||
391 | this.baseframelevel = this:GetFrameLevel(); |
||
392 | end |
||
393 | |||
394 | function DUF_Element_OnShow() |
||
395 | if (not DUF_INITIALIZED) then return; end |
||
396 | local unit = this:GetParent().unit; |
||
397 | local frameindex = DUF_FRAME_DATA[unit].index; |
||
398 | if (string.find(this:GetName(), "TargetHealthBar") or string.find(this:GetName(), "TargetManaBar") or this.checkname) then |
||
399 | unit = unit.."target"; |
||
400 | end |
||
401 | local color, bgcolor, bordercolor; |
||
402 | local context, bgcontext, bordercontext, bgstyle; |
||
403 | |||
404 | if (this.subindex) then |
||
405 | context = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].context; |
||
406 | bgcontext = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bgcontext; |
||
407 | bordercontext = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bordercontext; |
||
408 | else |
||
409 | context = DUF_Settings[DUF_INDEX][frameindex][this.index].context; |
||
410 | bgcontext = DUF_Settings[DUF_INDEX][frameindex][this.index].bgcontext; |
||
411 | bordercontext = DUF_Settings[DUF_INDEX][frameindex][this.index].bordercontext; |
||
412 | end |
||
413 | |||
414 | if ((not context) and (not bgcontext) and (not bordercontext)) then return; end |
||
415 | |||
416 | if (this.subindex) then |
||
417 | bgcolor = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bgcolor; |
||
418 | bordercolor = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bordercolor; |
||
419 | bgalpha = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bgalpha; |
||
420 | borderalpha = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].borderalpha; |
||
421 | else |
||
422 | bgcolor = DUF_Settings[DUF_INDEX][frameindex][this.index].bgcolor; |
||
423 | bordercolor = DUF_Settings[DUF_INDEX][frameindex][this.index].bordercolor; |
||
424 | bgalpha = DUF_Settings[DUF_INDEX][frameindex][this.index].bgalpha; |
||
425 | borderalpha = DUF_Settings[DUF_INDEX][frameindex][this.index].borderalpha; |
||
426 | end |
||
427 | |||
428 | local background = getglobal(this:GetName().."_Background"); |
||
429 | |||
430 | if (this.index == "StatusBar") then |
||
431 | if (this.subindex == 2 or this.subindex == 5) then |
||
432 | color = this.manacolor; |
||
433 | else |
||
434 | color = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].color; |
||
435 | end |
||
436 | elseif (this.index == "TextBox") then |
||
437 | color = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].textcolor; |
||
438 | else |
||
439 | color = bgcolor; |
||
440 | end |
||
441 | |||
442 | local r, g, b; |
||
443 | if (context and context < 4) then |
||
444 | if (context == 1) then |
||
445 | r, g ,b = DUF_Get_DifficultyColor(unit, color); |
||
446 | elseif (context == 2) then |
||
447 | r, g ,b = DUF_Get_ReactionColor(unit, color); |
||
448 | elseif (context == 3) then |
||
449 | r, g ,b = DUF_Get_ClassColor(unit, color); |
||
450 | end |
||
451 | DUF_Element_SetColor(r, g, b, bgstyle, bgalpha); |
||
452 | end |
||
453 | if (bgcontext and bgcontext < 4) then |
||
454 | if (bgcontext == 1) then |
||
455 | r, g ,b = DUF_Get_DifficultyColor(unit, bgcolor); |
||
456 | elseif (bgcontext == 2) then |
||
457 | r, g ,b = DUF_Get_ReactionColor(unit, bgcolor); |
||
458 | elseif (bgcontext == 3) then |
||
459 | r, g ,b = DUF_Get_ClassColor(unit, bgcolor); |
||
460 | end |
||
461 | background:SetBackdropColor(r, g, b, bgalpha); |
||
462 | end |
||
463 | if (bordercontext and bordercontext < 4) then |
||
464 | if (bordercontext == 1) then |
||
465 | r, g ,b = DUF_Get_DifficultyColor(unit, color); |
||
466 | elseif (bordercontext == 2) then |
||
467 | r, g ,b = DUF_Get_ReactionColor(unit, color); |
||
468 | elseif (bordercontext == 3) then |
||
469 | r, g ,b = DUF_Get_ClassColor(unit, color); |
||
470 | end |
||
471 | background:SetBackdropBorderColor(r, g, b, borderalpha); |
||
472 | end |
||
473 | end |
||
474 | |||
475 | function DUF_Element_OnUpdate(elapsed) |
||
476 | if (not DUF_INITIALIZED) then return; end |
||
477 | |||
478 | if (not this.timer) then this.timer = DUF_Settings[DUF_INDEX].updatespeed; end |
||
479 | if (not this.index) then return; end |
||
480 | |||
481 | if (this.flashing) then |
||
482 | this.flashtime = this.flashtime - elapsed; |
||
483 | if (this.flashtime < 0) then |
||
484 | this.flashtime = .5; |
||
485 | if (this.direction) then |
||
486 | this.direction = nil; |
||
487 | else |
||
488 | this.direction = 1; |
||
489 | end |
||
490 | end |
||
491 | if (this.direction) then |
||
492 | this:SetAlpha(1 - this.flashtime); |
||
493 | else |
||
494 | this:SetAlpha(this.flashtime + .5); |
||
495 | end |
||
496 | end |
||
497 | |||
498 | this.timer = this.timer - elapsed; |
||
499 | if (this.timer < 0) then |
||
500 | this.timer = DUF_Settings[DUF_INDEX].updatespeed; |
||
501 | if (this.index == "TextBox") then |
||
502 | this.update = true; |
||
503 | end |
||
504 | local unit = this:GetParent().unit; |
||
505 | local frameindex = DUF_FRAME_DATA[unit].index; |
||
506 | if (string.find(this:GetName(), "TargetHealthBar") or string.find(this:GetName(), "TargetManaBar") or this.checkname) then |
||
507 | unit = unit.."target"; |
||
508 | end |
||
509 | |||
510 | local context, bgcontext, bordercontext, flash, targetIcon; |
||
511 | if (this.subindex) then |
||
512 | context = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].context; |
||
513 | bgcontext = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bgcontext; |
||
514 | bordercontext = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bordercontext; |
||
515 | flash = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].flashlowhealth; |
||
516 | else |
||
517 | context = DUF_Settings[DUF_INDEX][frameindex][this.index].context; |
||
518 | bgcontext = DUF_Settings[DUF_INDEX][frameindex][this.index].bgcontext; |
||
519 | bordercontext = DUF_Settings[DUF_INDEX][frameindex][this.index].bordercontext; |
||
520 | flash = DUF_Settings[DUF_INDEX][frameindex][this.index].flashlowhealth; |
||
521 | end |
||
522 | |||
523 | if (flash) then |
||
524 | if (UnitHealth(unit) and UnitHealthMax(unit)) then |
||
525 | if (UnitHealth(unit) / UnitHealthMax(unit) <= DUF_Settings[DUF_INDEX].flashthreshold and UnitHealth(unit) > 0) then |
||
526 | if (not this.flashing) then |
||
527 | this.flashing = true; |
||
528 | this.direction = 1; |
||
529 | this.flashtime = .5; |
||
530 | end |
||
531 | else |
||
532 | this.flashing = nil; |
||
533 | if (this.subindex) then |
||
534 | this:SetAlpha(DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].alpha); |
||
535 | else |
||
536 | this:SetAlpha(DUF_Settings[DUF_INDEX][frameindex][this.index].alpha); |
||
537 | end |
||
538 | end |
||
539 | end |
||
540 | end |
||
541 | |||
542 | if ((not context) and (not bgcontext) and (not bordercontext)) then return; end |
||
543 | |||
544 | local color, bgcolor, bordercolor; |
||
545 | if (this.subindex) then |
||
546 | bgcolor = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bgcolor; |
||
547 | bordercolor = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bordercolor; |
||
548 | bgstyle = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].backgroundstyle; |
||
549 | bgalpha = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].bgalpha; |
||
550 | borderalpha = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].borderalpha; |
||
551 | else |
||
552 | bgcolor = DUF_Settings[DUF_INDEX][frameindex][this.index].bgcolor; |
||
553 | bordercolor = DUF_Settings[DUF_INDEX][frameindex][this.index].bordercolor; |
||
554 | bgstyle = DUF_Settings[DUF_INDEX][frameindex][this.index].backgroundstyle; |
||
555 | bgalpha = DUF_Settings[DUF_INDEX][frameindex][this.index].bgalpha; |
||
556 | borderalpha = DUF_Settings[DUF_INDEX][frameindex][this.index].borderalpha; |
||
557 | end |
||
558 | |||
559 | if (this.index == "StatusBar") then |
||
560 | if (this.subindex == 2 or this.subindex == 5) then |
||
561 | color = this.manacolor; |
||
562 | else |
||
563 | color = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].color; |
||
564 | end |
||
565 | elseif (this.index == "TextBox") then |
||
566 | color = DUF_Settings[DUF_INDEX][frameindex][this.index][this.subindex].textcolor; |
||
567 | else |
||
568 | color = bgcolor; |
||
569 | end |
||
570 | local r, g, b; |
||
571 | if (context == 4 or bgcontext == 4 or bordercontext == 4) then |
||
572 | local health = UnitHealth(unit); |
||
573 | local healthmax = UnitHealthMax(unit); |
||
574 | if (this.health ~= health or this.healthmax ~= this.healthmax) then |
||
575 | this.health = health; |
||
576 | this.healthmax = healthmax; |
||
577 | if (context == 4) then |
||
578 | r, g, b = DUF_Get_HealthColor(unit, color); |
||
579 | DUF_Element_SetColor(r, g, b, bgstyle, bgalpha); |
||
580 | end |
||
581 | if (bgcontext == 4) then |
||
582 | r, g, b = DUF_Get_HealthColor(unit, bgcolor); |
||
583 | getglobal(this:GetName().."_Background"):SetBackdropColor(r, g, b, bgalpha); |
||
584 | end |
||
585 | if (bordercontext == 4) then |
||
586 | r, g, b = DUF_Get_HealthColor(unit, bordercolor); |
||
587 | getglobal(this:GetName().."_Background"):SetBackdropBorderColor(r, g, b, borderalpha); |
||
588 | end |
||
589 | end |
||
590 | end |
||
591 | if (context == 5 or bgcontext == 5 or bordercontext == 5) then |
||
592 | local mana = UnitMana(unit); |
||
593 | local manamax = UnitManaMax(unit); |
||
594 | if (this.mana ~= mana or this.manamax ~= this.manamax) then |
||
595 | this.mana = mana; |
||
596 | this.manamax = manamax; |
||
597 | if (context == 5) then |
||
598 | if (not color) then return; end |
||
599 | r, g, b = DUF_Get_ManaColor(unit, color); |
||
600 | DUF_Element_SetColor(r, g, b, bgstyle, bgalpha); |
||
601 | end |
||
602 | if (bgcontext == 5) then |
||
603 | r, g, b = DUF_Get_ManaColor(unit, bgcolor); |
||
604 | getglobal(this:GetName().."_Background"):SetBackdropColor(r, g, b, bgalpha); |
||
605 | end |
||
606 | if (bordercontext == 5) then |
||
607 | r, g, b = DUF_Get_ManaColor(unit, bordercolor); |
||
608 | getglobal(this:GetName().."_Background"):SetBackdropBorderColor(r, g, b, borderalpha); |
||
609 | end |
||
610 | end |
||
611 | end |
||
612 | if (context == 2 or bgcontext == 2 or bordercontext == 2) then |
||
613 | local reaction = DUF_Get_Reaction(unit); |
||
614 | if (this.reaction ~= reaction) then |
||
615 | this.reaction = reaction; |
||
616 | if (context == 2) then |
||
617 | if (not color) then return; end |
||
618 | r, g, b = DUF_Get_ReactionColor(unit, color); |
||
619 | DUF_Element_SetColor(r, g, b, bgstyle, bgalpha); |
||
620 | end |
||
621 | if (bgcontext == 2) then |
||
622 | r, g, b = DUF_Get_ReactionColor(unit, bgcolor); |
||
623 | getglobal(this:GetName().."_Background"):SetBackdropColor(r, g, b, bgalpha); |
||
624 | end |
||
625 | if (bordercontext == 2) then |
||
626 | r, g, b = DUF_Get_ReactionColor(unit, bordercolor); |
||
627 | getglobal(this:GetName().."_Background"):SetBackdropBorderColor(r, g, b, borderalpha); |
||
628 | end |
||
629 | end |
||
630 | end |
||
631 | end |
||
632 | end |
||
633 | |||
634 | function DUF_Element_SetColor(r, g, b, bgstyle, alpha) |
||
635 | if (this.index == "StatusBar") then |
||
636 | getglobal(this:GetName().."_Bar"):SetVertexColor(r, g, b); |
||
637 | elseif (this.index == "TextBox") then |
||
638 | getglobal(this:GetName().."_Text"):SetTextColor(r, g, b); |
||
639 | else |
||
640 | getglobal(this:GetName().."_Background"):SetBackdropColor(r, g, b, alpha); |
||
641 | end |
||
642 | end |