vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Bindings
2 BINDING_HEADER_ECASTINGBAR = "eCastingBar"
3 BINDING_NAME_ECASTINGBARDLG = "Toggle Configuration Window";
4 ECASTINGBAR_TITLE = "Configure eCastingBar"
5  
6 -- Global constants
7 CASTING_BAR_MAJOR_VERSION = "1";
8 CASTING_BAR_MINOR_VERSION = "3";
9 CASTING_BAR_REVISION = "19";
10 CASTING_BAR_ALPHA_STEP = 0.05;
11 CASTING_BAR_FLASH_STEP = 0.2;
12 CASTING_BAR_HOLD_TIME = 1;
13 CASTING_BAR_WIDTH = 264;
14 CASTING_BAR_HEIGHT = 30;
15 CASTING_BAR_SLIDER_WIDTH_MIN = 100;
16 CASTING_BAR_SLIDER_WIDTH_MAX = 2000;
17 CASTING_BAR_SLIDER_HEIGHT_MIN = 20;
18 CASTING_BAR_SLIDER_HEIGHT_MAX = 60;
19 CASTING_BAR_DEFAULT_SPELL_LENGTH = -1 -- show all
20 CASTING_BAR_DEFAULT_SPELL_JUSTIFY = "Center"
21  
22  
23 -- Global variables
24 eCastingBar_Saved = {};
25 eCastingBar_Player = nil;
26 eCastingBar_Resolution = nil;
27 eCastingBar_ResolutionWidth = 0;
28 eCastingBar_ResolutionHeight = 0;
29 eCastingBar_MENU_SAVEDSETTINGS = nil;
30 eCastingBar_SETTINGS_INDEX = "";
31  
32 -- Local Constants
33 local CASTING_BAR_DEFAULT_TEXTURE = "Interface\\TargetingFrame\\UI-StatusBar";
34 local CASTING_BAR_PERL_TEXTURE = "Interface\\AddOns\\eCastingBar\\Textures\\StatusBar.tga";
35 local CASTING_BAR_COLOR_TEXTURE = "Interface\\AddOns\\eCastingBar\\Textures\\RoundedLightSample.tga";
36 local CASTING_BAR_BACKGROUND_FILE = "Interface\\Tooltips\\UI-Tooltip-Background";
37 local CASTING_BAR_EDGE_FILE = "Interface\\Tooltips\\UI-Tooltip-Border";
38  
39 -- Casting Bar Frame Suffixes
40 local frameSuffixes = { "" }
41  
42 local CASTING_BAR_DEFAULTS = {
43 ["Locked"] = 0,
44 ["Enabled"] = 1,
45 ["UsePerlTexture"] = 1,
46 ["ShowTime"] = 1,
47 ["HideBorder"] = 0,
48 ["ShowDelay"] = 1,
49 ["Width"] = CASTING_BAR_WIDTH,
50 ["Height"] = CASTING_BAR_HEIGHT,
51 ["Left"] = 300,
52 ["Bottom"] = 300,
53 ["SpellLength"] = CASTING_BAR_DEFAULT_SPELL_LENGTH,
54 ["SpellJustify"] = CASTING_BAR_DEFAULT_SPELL_JUSTIFY,
55 ["FontSize"] = 12,
56 ["MirrorLocked"] = 0,
57 ["MirrorEnabled"] = 1,
58 ["MirrorUsePerlTexture"] = 1,
59 ["MirrorShowTime"] = 1,
60 ["MirrorHideBorder"] = 0,
61 ["MirrorWidth"] = CASTING_BAR_WIDTH,
62 ["MirrorHeight"] = CASTING_BAR_HEIGHT,
63 ["MirrorLeft"] = 300,
64 ["MirrorBottom"] = 400,
65 ["MirrorSpellLength"] = CASTING_BAR_DEFAULT_SPELL_LENGTH,
66 ["MirrorSpellJustify"] = CASTING_BAR_DEFAULT_SPELL_JUSTIFY,
67 ["MirrorFontSize"] = 12
68 }
69  
70 local CASTING_BAR_DEFAULT_COLORS = {
71 ["SpellColor"] = {1.0, 0.7, 0.0, 1.0},
72 ["ChannelColor"] = {0.3, 0.3, 1.0, 1},
73 ["SuccessColor"] = {0.0, 1.0, 0.0, 1},
74 ["FailedColor"] = {1.0, 0.0, 0.0, 1},
75 ["FlashBorderColor"] = {1.0, 0.88, 0.25, 1},
76 ["FeignDeathColor"] = {1.0, 0.7, 0.0, 1},
77 ["ExhaustionColor"] = {1.0, 0.9, 0.0, 1},
78 ["BreathColor"] = {0.0, 0.5, 1.0, 1},
79 ["TimeColor"] = {1.0, 1.0, 1.0, 1},
80 ["DelayColor"] = {1.0, 0.0, 0.0, 1},
81 ["MirrorTimeColor"] = {1.0, 1.0, 1.0, 1},
82 ["MirrorFlashBorderColor"] = {1.0, 0.88, 0.25, 1},
83 }
84 -- local variables
85  
86 local eCastingBar__FlashBorders = {
87 "TOPLEFT",
88 "TOP",
89 "TOPRIGHT",
90 "LEFT",
91 "RIGHT",
92 "BOTTOMLEFT",
93 "BOTTOM",
94 "BOTTOMRIGHT"
95 }
96  
97 local eCastingBar__Events = {
98 "SPELLCAST_START",
99 "SPELLCAST_STOP",
100 "SPELLCAST_INTERRUPTED",
101 "SPELLCAST_FAILED",
102 "SPELLCAST_DELAYED",
103 "SPELLCAST_CHANNEL_START",
104 "SPELLCAST_CHANNEL_UPDATE",
105 "MIRROR_TIMER_START"
106 }
107  
108  
109 local eCastingBar__CastTimeEvents = {
110 "SPELLCAST_START",
111 "SPELLCAST_STOP",
112 "SPELLCAST_INTERRUPTED",
113 "SPELLCAST_FAILED"
114 }
115  
116 -- FlightMap vars
117 local eCB_FM_TakeTaxiNode = function() end;
118  
119 function ECB_addChat(msg)
120 DEFAULT_CHAT_FRAME:AddMessage(CASTINGBAR_HEADER.." "..msg)
121 end
122  
123 function eCastingBar_Toggle()
124 if eCastingBarConfigFrame:IsVisible() then
125 eCastingBarConfigFrame:Hide()
126 else
127 eCastingBarConfigFrame:Show()
128 end
129 end
130  
131 --[[ onFoo stuff ]]--
132 function eCastingBar_OnLoad()
133  
134 -- load the new castingbar:
135 eCastingBar:RegisterEvent("PLAYER_ENTERING_WORLD")
136 eCastingBar:RegisterEvent("VARIABLES_LOADED")
137 end
138  
139 --[[
140 This function will check for the Flight Map Addon
141 If found, we will overwrite their OnEnter function with ours.
142 ]]--
143 function eCastingBar_CheckFlightMapAddon()
144 if (FlightMapFrame) then
145 -- store the FlightPath TaxiNodeOnButtonEnter function
146 eCB_FM_TakeTaxiNode = TakeTaxiNode
147 -- hook our function up
148 TakeTaxiNode = eCastingBar_TakeTaxiNode;
149 end
150 end
151  
152 function eCastingBar_TakeTaxiNode(id)
153 -- first call the Flight Maps TakeTaxiNode
154 eCB_FM_TakeTaxiNode(id)
155  
156 eCastingBar_SetTaxiInfo()
157 end
158  
159 function eCastingBar_SetTaxiInfo()
160 -- now we will use the values for the taxi node for the casting bar
161 if (FlightMapTimesFrame) then
162 if (FlightMapTimesFrame:IsVisible()) then
163 if (eCastingBar_Saved[eCastingBar_Player].Enabled == 1) then
164 -- grab all the values for this casting bar
165 local intDuration = nil
166  
167 if (FlightMapTimesFrame.endTime ~= nil) then
168 intDuration = (FlightMapTimesFrame.endTime - FlightMapTimesFrame.startTime) * 1000
169 end
170  
171 eCastingBar.OnTaxi = true;
172 eCastingBar_SpellcastChannelStart( "", intDuration , FlightMapTimesFrame.endPoint )
173 ECB_addChat("Value: " .. FlightMapTimesFrame:GetValue())
174 eCastingBarStatusBar:SetValue(FlightMapTimesFrame:GetValue())
175  
176 -- store the flight map position
177 eCastingBar_Saved[eCastingBar_Player].FlightMapX = FlightMapTimesFrame:GetLeft()
178 eCastingBar_Saved[eCastingBar_Player].FlightMapY = FlightMapTimesFrame:GetBottom()
179  
180 -- now move the frame off the screen
181 FlightMapTimesFrame:ClearAllPoints()
182 FlightMapTimesFrame:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", -2000, 2000 )
183 end
184 end
185 end
186 end
187  
188 --[[ Registers "frame" (passed as a string) to spellcast events. ]]--
189 function eCastingBar_Register( frmFrame, strEvent )
190  
191 -- register event.
192 getglobal( frmFrame ):RegisterEvent( strEvent )
193  
194 end
195  
196 --[[ Unregisters "frame" (passed as a string) from spellcast events. ]]--
197 function eCastingBar_Unregister( frmFrame, strEvent )
198  
199 -- ungregister event.
200 getglobal( frmFrame ):UnregisterEvent( strEvent )
201  
202 end
203  
204 --[[ Handles all the mods' events. ]]--
205 function eCastingBar_OnEvent( frame )
206  
207 if event == "PLAYER_ENTERING_WORLD" then
208  
209 -- inform the user we are starting loading .
210 ECB_addChat( CASTINGBAR_LOADED )
211  
212 eCastingBar:UnregisterEvent( event )
213  
214 eCastingBar_Player = UnitName( "player" ).. " - " ..GetRealmName( )
215  
216 -- hide all bars
217 for index, option in frameSuffixes do
218 getglobal("eCastingBar"..option):Hide();
219 end
220  
221 --is the save empty or broken?
222 if not eCastingBar_Saved[eCastingBar_Player] or eCastingBar_Saved[eCastingBar_Player] == 1 then
223 eCastingBar_Saved[eCastingBar_Player] = {}
224  
225 --yes, inform the user we are loaing defaults
226 ECB_addChat( " First Load or broken save, Loading defaults." )
227  
228 --set it to defaults
229 eCastingBar_ResetSettings()
230 end
231  
232 eCastingBar_CheckSettings()
233  
234 eCastingBar_LoadVariables()
235  
236 -- check for FlightMap Addon
237 eCastingBar_CheckFlightMapAddon()
238  
239 end
240  
241 --if( event == "VARIABLES_LOADED" ) then
242  
243 -- load the variables
244  
245 --end
246  
247 if( event == "SPELLCAST_START" ) then
248  
249 -- arg1 = Spell Name
250 -- arg2 = Duration (in milliseconds)
251 eCastingBar_SpellcastStart( frame, arg1, arg2 )
252  
253 elseif( event == "SPELLCAST_STOP" ) then
254  
255 eCastingBar_SpellcastStop( frame )
256  
257 elseif( event == "SPELLCAST_FAILED" or event == "SPELLCAST_INTERRUPTED" ) then
258  
259 eCastingBar_SpellcastFailed( frame )
260  
261 elseif( event == "SPELLCAST_DELAYED" ) then
262  
263 -- arg1 = Disruption Time(in milliseconds)
264 eCastingBar_SpellcastDelayed( frame, arg1 )
265  
266 elseif( event == "SPELLCAST_CHANNEL_START" ) then
267  
268 -- arg1 = Duration (in milliseconds)
269 -- arg2 = Spell Name
270 eCastingBar_SpellcastChannelStart( frame, arg1, arg2 )
271  
272 elseif( event == "SPELLCAST_CHANNEL_UPDATE" ) then
273  
274 -- arg1 = Remaining Duration (in milliseconds)
275 eCastingBar_SpellcastChannelUpdate( frame, arg1 )
276 end
277  
278 -- check for mirros
279 if( event == "MIRROR_TIMER_START" ) then
280 if (eCastingBar_Saved[eCastingBar_Player].MirrorEnabled == 1) then
281 -- if we are not using Blizzards timers we should hide it.
282 if (eCastingBar_Saved[eCastingBar_Player].MirrorEnabled == 1) then
283 hideBlizzardMirrorFrame(arg1)
284 else
285 -- else make sure its shown
286 showBlizzardMirrorFrame(arg1)
287 end
288 eCastingBarMirror_Show(arg1, arg2, arg3, arg4, arg5, arg6)
289 end
290 end
291 end
292  
293 function hideBlizzardMirrorFrame(timer)
294 -- hide the Blizzard frame
295 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
296 local frame = getglobal("MirrorTimer"..index)
297 if (frame.timer == timer) then
298 frame:Hide()
299 end
300 end
301 end
302  
303 function showBlizzardMirrorFrame(timer)
304 -- hide the Blizzard frame
305 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
306 local frame = getglobal("MirrorTimer"..index)
307 if (frame.timer == timer) then
308 frame:Show()
309 end
310 end
311 end
312  
313 function hideAllBlizzardMirrorFrames()
314 -- hide the Blizzard frame
315 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
316 local frame = getglobal("MirrorTimer"..index)
317 local frame2 = getglobal("eCastingBarMirror"..index)
318  
319 if (frame2.timer ~= nil) then
320 frame:Hide()
321 frame2:Show()
322 end
323 end
324 end
325  
326  
327 function showAllBlizzardMirrorFrames()
328 -- hide the Blizzard frame
329 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
330 local frame = getglobal("MirrorTimer"..index)
331 local frame2 = getglobal("eCastingBarMirror"..index)
332 if (frame.timer ~= nil) then
333 frame:Show()
334 frame2:Hide()
335 end
336 end
337 end
338  
339 function eCastingBar_ResetSettings()
340 ECB_addChat("Resetting Default Settings")
341 eCastingBar_Saved[eCastingBar_Player] = {}
342 -- Reset General Options
343 for option in CASTING_BAR_DEFAULTS do
344 eCastingBar_Saved[eCastingBar_Player][option] = CASTING_BAR_DEFAULTS[option]
345 end
346  
347 -- Reset Colors
348 for color in CASTING_BAR_DEFAULT_COLORS do
349 eCastingBar_Saved[eCastingBar_Player][color] = CASTING_BAR_DEFAULT_COLORS[color]
350 end
351  
352  
353 setup()
354 end
355  
356 function eCastingBar_CheckSettings()
357 -- Reset General Options
358 for option in CASTING_BAR_DEFAULTS do
359 if (eCastingBar_Saved[eCastingBar_Player][option] == nil) then
360 eCastingBar_Saved[eCastingBar_Player][option] = CASTING_BAR_DEFAULTS[option]
361 end
362 end
363  
364 -- check for nil colors
365 for color in CASTING_BAR_DEFAULT_COLORS do
366 if (eCastingBar_Saved[eCastingBar_Player][color] == nil) then
367 eCastingBar_Saved[eCastingBar_Player][color] = CASTING_BAR_DEFAULT_COLORS[color]
368 end
369 end
370 end
371  
372 function setup()
373 eCastingBar_checkEnabled()
374 eCastingBar_checkLocked()
375 eCastingBar_checkBorders()
376 eCastingBar_checkTimeColors( )
377 eCastingBar_setDelayColor()
378 eCastingBar_SetSize()
379 eCastingBar_checkFlashBorderColors()
380 eCastingBar_checkTextures()
381 end
382  
383 --[[ Iniitialization ]]--
384 function eCastingBar_LoadVariables( )
385 setup()
386 eCastingBar_SetSavedSettingsMenu()
387  
388 -- set the loaded variables
389  
390 -- make the casting bar link to the movable button
391 eCastingBar:SetPoint("TOPLEFT", "eCastingBar_Outline", "TOPLEFT", 0, 0 )
392  
393 -- make the mirror casting bar link to the movable button
394 eCastingBarMirror1:SetPoint("TOPLEFT", "eCastingBarMirror_Outline", "TOPLEFT", 0, 0 )
395  
396 -- reset variables
397 for index, option in frameSuffixes do
398 getglobal("eCastingBar"..option).casting = nil
399 getglobal("eCastingBar"..option).holdTime = 0
400 end
401  
402 -- code used if no cosmos is present
403  
404 -- make the slash commands
405 SlashCmdList["ECASTINGBAR"] = eCastingBar_SlashHandler
406 SLASH_ECASTINGBAR1 = "/eCastingBar"
407 SLASH_ECASTINGBAR2 = "/eCB"
408  
409 -- resolution
410 SetResolution(GetScreenResolutions())
411 local i,j = string.find(eCastingBar_Resolution, "x")
412  
413 --eCastingBar_ResolutionWidth = tonumber(string.sub(eCastingBar_Resolution, 0, i - 1))
414 --eCastingBar_ResolutionHeight = tonumber(string.sub(eCastingBar_Resolution, i + 1, string.len(eCastingBar_Resolution)))
415  
416 -- override these for now until I can figure out why blizzard is jacked up
417 eCastingBar_ResolutionWidth = 2000
418 eCastingBar_ResolutionHeight = 2000
419  
420 setupConfigFrame()
421 setupDefaultConfigFrame()
422 setupColorsConfigFrame()
423 end
424  
425 function setupConfigFrame()
426 -- set all text values --
427 eCastingBarGeneralsSelect:SetText(CASTINGBAR_GENERAL_BUTTON)
428 eCastingBarMirrorSelect:SetText(CASITINGBARMIRROR_BUTTON)
429 eCastingBarColorsSelect:SetText(CASTINGBAR_COLOR_BUTTON)
430 eDefaultsConfigButton:SetText(CASTINGBAR_DEFAULTS_BUTTON)
431 eCloseConfigButton:SetText(CASTINGBAR_CLOSE_BUTTON)
432 eCastingBarSaveSettingsButton:SetText(CASTINGBAR_SAVE_BUTTON)
433 eCastingBarLoadSettingsButton:SetText(CASTINGBAR_LOAD_BUTTON)
434 eCastingBarDeleteSettingsButton:SetText(CASTINGBAR_DELETE_BUTTON)
435 end
436  
437 function setupDefaultConfigFrame()
438 -- set all text values --
439 for option in CASTING_BAR_BUTTONS do
440 local btnText = getglobal("eCastingBar"..option.."Text")
441 btnText:SetText(CASTING_BAR_BUTTONS[option])
442 end
443  
444 eCastingBarSpellLength:SetNumber(eCastingBar_Saved[eCastingBar_Player].SpellLength)
445 eCastingBarSpellLengthText:SetText(CASTINGBAR_SPELL_LENGTH_TEXT)
446 eCastingBarSpellJustify_Label:SetText(CASTINGBAR_SPELL_JUSTIFY_TEXT)
447 eCastingBarSpellJustify_Setting:SetText(eCastingBar_Saved[eCastingBar_Player].SpellJustify)
448 eCastingBarText:SetJustifyH(eCastingBar_Saved[eCastingBar_Player].SpellJustify)
449  
450 eCastingBarMirrorSpellLength:SetNumber(eCastingBar_Saved[eCastingBar_Player].MirrorSpellLength)
451 eCastingBarMirrorSpellLengthText:SetText(CASTINGBARMIRROR_SPELL_LENGTH_TEXT)
452 eCastingBarMirrorSpellJustify_Label:SetText(CASTINGBARMIRROR_SPELL_JUSTIFY_TEXT)
453 eCastingBarMirrorSpellJustify_Setting:SetText(eCastingBar_Saved[eCastingBar_Player].MirrorSpellJustify)
454  
455 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
456 getglobal("eCastingBarMirror"..index.."StatusBarText"):SetJustifyH(eCastingBar_Saved[eCastingBar_Player].MirrorSpellJustify)
457 end
458  
459 -- set all checks
460 for option in CASTING_BAR_BUTTONS do
461 local btn = getglobal("eCastingBar"..option)
462 btn:SetChecked(eCastingBar_Saved[eCastingBar_Player][option])
463 end
464  
465 local slider, sliderText, low, high, width, height
466  
467 local optionTabs = { "", "Mirror" }
468  
469 for index, option in optionTabs do
470 -- setup the width slider
471 slider = getglobal("eCastingBar"..option.."WidthSlider")
472 sliderText = getglobal("eCastingBar"..option.."WidthSliderText")
473 low = getglobal("eCastingBar"..option.."WidthSliderLow")
474 high = getglobal("eCastingBar"..option.."WidthSliderHigh")
475  
476 slider:SetMinMaxValues(CASTING_BAR_SLIDER_WIDTH_MIN, eCastingBar_ResolutionWidth)
477 slider:SetValueStep(1)
478 slider:SetValue(eCastingBar_Saved[eCastingBar_Player][option.."Width"])
479 sliderText:SetText(CASTINGBAR_SLIDER_WIDTH_TEXT)
480 low:SetText(CASTING_BAR_SLIDER_WIDTH_MIN)
481 high:SetText(eCastingBar_ResolutionWidth)
482  
483 -- setup the height slider
484 slider = getglobal("eCastingBar"..option.."HeightSlider")
485 sliderText = getglobal("eCastingBar"..option.."HeightSliderText")
486 low = getglobal("eCastingBar"..option.."HeightSliderLow")
487 high = getglobal("eCastingBar"..option.."HeightSliderHigh")
488  
489  
490 slider:SetMinMaxValues(CASTING_BAR_SLIDER_HEIGHT_MIN, CASTING_BAR_SLIDER_HEIGHT_MAX)
491 slider:SetValueStep(1)
492 slider:SetValue(eCastingBar_Saved[eCastingBar_Player][option.."Height"])
493 sliderText:SetText(CASTINGBAR_SLIDER_HEIGHT_TEXT)
494 low:SetText(CASTING_BAR_SLIDER_HEIGHT_MIN)
495 high:SetText(CASTING_BAR_SLIDER_HEIGHT_MAX)
496  
497 -- setup the x slider
498 slider = getglobal("eCastingBar"..option.."LeftSlider")
499 sliderText = getglobal("eCastingBar"..option.."LeftSliderText")
500 low = getglobal("eCastingBar"..option.."LeftSliderLow")
501 high = getglobal("eCastingBar"..option.."LeftSliderHigh")
502  
503 if (option == "Mirror") then
504 width = tonumber(string.format("%.0f", getglobal("eCastingBarMirror1"):GetWidth()))
505 height = tonumber(string.format("%.0f", getglobal("eCastingBarMirror1"):GetHeight()))
506 else
507 width = tonumber(string.format("%.0f", getglobal("eCastingBar"..option):GetWidth()))
508 height = tonumber(string.format("%.0f", getglobal("eCastingBar"..option):GetHeight()))
509 end
510  
511 slider:SetMinMaxValues(-1000, eCastingBar_ResolutionWidth)
512 slider:SetValueStep(1)
513 slider:SetValue(eCastingBar_Saved[eCastingBar_Player][option.."Left"])
514 sliderText:SetText(CASTINGBAR_SLIDER_LEFT_TEXT)
515 low:SetText(-1000)
516 high:SetText(eCastingBar_ResolutionWidth)
517  
518 -- setup the y slider
519 slider = getglobal("eCastingBar"..option.."BottomSlider")
520 sliderText = getglobal("eCastingBar"..option.."BottomSliderText")
521 low = getglobal("eCastingBar"..option.."BottomSliderLow")
522 high = getglobal("eCastingBar"..option.."BottomSliderHigh")
523  
524 slider:SetMinMaxValues(-1000, eCastingBar_ResolutionHeight)
525 slider:SetValueStep(1)
526 slider:SetValue(eCastingBar_Saved[eCastingBar_Player][option.."Bottom"])
527 sliderText:SetText(CASTINGBAR_SLIDER_BOTTOM_TEXT)
528 low:SetText(-1000)
529 high:SetText(eCastingBar_ResolutionHeight)
530  
531 -- setup the font slider
532 slider = getglobal("eCastingBar"..option.."FontSlider")
533 sliderText = getglobal("eCastingBar"..option.."FontSliderText")
534 low = getglobal("eCastingBar"..option.."FontSliderLow")
535 high = getglobal("eCastingBar"..option.."FontSliderHigh")
536  
537 slider:SetMinMaxValues(12, 24)
538 slider:SetValueStep(1)
539 slider:SetValue(eCastingBar_Saved[eCastingBar_Player][option.."FontSize"])
540 sliderText:SetText(CASTINGBAR_SLIDER_FONT_TEXT)
541 low:SetText(12)
542 high:SetText(24)
543 end
544 end
545  
546 function setupColorsConfigFrame()
547 -- set the textures --
548 for color in CASTINGBAR_COLOR_LABEL do
549 local btnColor = getglobal("btn"..color.."Texture")
550  
551 -- set the texture
552 btnColor:SetTexture(CASTING_BAR_COLOR_TEXTURE)
553  
554 -- set the vertex color
555 btnColor:SetVertexColor(unpack(eCastingBar_Saved[eCastingBar_Player][color]))
556  
557 -- set the label
558 getglobal("lbl"..color.."Text"):SetText(CASTINGBAR_COLOR_LABEL[color])
559 end
560 end
561  
562 function SetResolution(...)
563 local iRes = GetCurrentResolution()
564  
565 for i=1, arg.n, 1 do
566 if (iRes == i) then
567 eCastingBar_Resolution = arg[i]
568 end
569 end
570 end
571  
572  
573 --[[ Handles all the slash commands if cosmos isn't present. ]]--
574 function eCastingBar_SlashHandler( strMessage )
575 local command, param
576 -- make it it all lower case to be sure
577 strMessage = string.lower( strMessage )
578  
579 if(index) then
580 command = string.sub(strMessage, 1, (index - 1))
581 param = string.sub(strMessage, (index + 1) )
582 else
583 command = strMessage
584 end
585  
586 if( command == CASTINGBAR_CHAT_C1 ) then
587 -- show the config window
588 getglobal("eCastingBarConfigFrame"):Show()
589  
590 -- no, did they type: help?
591 elseif ( command == CASTINGBAR_CHAT_C2) then
592 -- call for help
593 eCastingBar_ChatHelp()
594  
595 -- no: do default
596 else
597  
598 -- show the config window
599 getglobal("eCastingBarConfigFrame"):Show()
600  
601 end
602  
603 setupDefaultConfigFrame()
604 setupColorsConfigFrame()
605  
606 end
607  
608 --[[ Handles chat help messages. ]]--
609 function eCastingBar_ChatHelp( )
610  
611 local intIndex = 0
612 local strMessage = ""
613  
614 -- prints each line in CASTINGBAR_HELP = { }
615 for intIndex, strMessage in CASTINGBAR_HELP do
616  
617 ECB_addChat( strMessage )
618  
619 end
620  
621 end
622  
623 --[[ Handles the SPELLCAST_START event. ]]--
624 function eCastingBar_SpellcastStart( fraFrame, strSpellName, intDuration )
625 -- set the bar color
626 local Red, Green, Blue, Alpha
627 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player].SpellColor)
628 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetStatusBarColor( Red, Green, Blue, Alpha )
629  
630 -- show the spark
631 getglobal("eCastingBar"..fraFrame.."Spark"):Show( )
632  
633 -- set the start and max time
634 getglobal("eCastingBar"..fraFrame).startTime = GetTime( )
635 getglobal("eCastingBar"..fraFrame).initStartTime = GetTime( )
636  
637 -- if the duration is nil set it to 10 minutes. Nothing should last this long
638 if (intDuration == nil) then
639 intDuration = 600000
640 end
641 getglobal("eCastingBar"..fraFrame).maxValue = getglobal("eCastingBar"..fraFrame).startTime + ( intDuration / 1000 )
642  
643 -- set the bar minium and maxium accordingly (basicly it will grow as time passes)
644 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetMinMaxValues( getglobal("eCastingBar"..fraFrame).startTime, getglobal("eCastingBar"..fraFrame).maxValue )
645  
646 -- set the bar to empty
647 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetValue( getglobal("eCastingBar"..fraFrame).startTime )
648  
649 -- set the text to the spell name
650 -- figure out how much to show
651 if ( eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"] == -1 ) then
652 -- show all
653 getglobal("eCastingBar"..fraFrame.."Text"):SetText( strSpellName )
654 elseif ( eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"] == 0) then
655 -- dont show it
656 getglobal("eCastingBar"..fraFrame.."Text"):SetText( "" )
657 else
658 -- if the size of the name is less than or equal to the max size, just show it all
659 if ( string.len(strSpellName) <= eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"] ) then
660 getglobal("eCastingBar"..fraFrame.."Text"):SetText( strSpellName )
661 else
662 getglobal("eCastingBar"..fraFrame.."Text"):SetText( string.sub(strSpellName , 1, eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"]) )
663 end
664 end
665  
666 -- set the bar to fully opaque
667 getglobal("eCastingBar"..fraFrame):SetAlpha( 1.0 )
668  
669 -- start the casting state, and make sure everything else is reset
670 getglobal("eCastingBar"..fraFrame).holdTime = 0
671 getglobal("eCastingBar"..fraFrame).casting = 1
672 getglobal("eCastingBar"..fraFrame).fadeOut = nil
673 getglobal("eCastingBar"..fraFrame).delay = 0
674 getglobal("eCastingBar"..fraFrame):Show( )
675 getglobal("eCastingBar"..fraFrame).mode = "casting"
676  
677 end
678  
679 --[[ Handles the SPELLCAST_STOP event. ]]--
680 function eCastingBar_SpellcastStop( fraFrame )
681  
682 -- NOTE: not sure why but certain things in here keep getting called everytime channeling updates
683 -- first the green bar colored used for success, forced channeling green also (no matter what i did)
684 -- so don't put anything in here that will fuck w/ channeling, unless you use if( eCastingBar.channeling == nil)
685  
686 -- test
687  
688 -- make sure we aren't channeling first
689 if( getglobal("eCastingBar"..fraFrame).channeling == nil ) then
690  
691 -- set the bar color
692 local Red, Green, Blue, Alpha
693 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player].SuccessColor)
694 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetStatusBarColor( Red, Green, Blue, Alpha )
695 getglobal("eCastingBar"..fraFrame.."Spark"):Hide( )
696  
697 end
698  
699 -- is the bar still visiable?
700 if ( not getglobal("eCastingBar"..fraFrame):IsVisible( ) ) then
701  
702 -- yes, we are done casting, so hide it
703 getglobal("eCastingBar"..fraFrame):Hide( )
704  
705 end
706  
707 -- is the bar still shown? ( not sure what the difference between this and :IsVisible, but there is (figure it out!) )
708 if ( getglobal("eCastingBar"..fraFrame):IsShown( ) ) then
709  
710 -- set the bar to max value (visually helps the user see)
711 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetValue( getglobal("eCastingBar"..fraFrame).maxValue )
712  
713 -- start the flash state
714 getglobal("eCastingBar"..fraFrame.."Flash"):SetAlpha( 0.0 )
715 getglobal("eCastingBar"..fraFrame.."Flash"):Show( )
716 getglobal("eCastingBar"..fraFrame).casting = nil
717 getglobal("eCastingBar"..fraFrame).OnTaxi = nil
718 getglobal("eCastingBar"..fraFrame).flying = nil
719 getglobal("eCastingBar"..fraFrame).delay = 0
720 getglobal("eCastingBar"..fraFrame).flash = 1
721 getglobal("eCastingBar"..fraFrame).fadeOut = 1
722 getglobal("eCastingBar"..fraFrame).mode = "flash"
723  
724 end
725  
726 end
727  
728 --[[ Handles the SPELLCAST_FAILED and SPELLCAST_INTERRUPTED events. ]]--
729 function eCastingBar_SpellcastFailed( fraFrame )
730 -- first make sure we are not flying. if so, just ignore this
731 if (getglobal("eCastingBar"..fraFrame).flying) then return; end
732  
733 -- is the bar still shown? ( not sure what the difference between this and :IsVisiable, but there is (figure it out!) )
734 if ( getglobal("eCastingBar"..fraFrame):IsShown( ) ) then
735  
736 -- set the bar to max (visually helps the user see)
737 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetValue( getglobal("eCastingBar"..fraFrame).maxValue )
738  
739 -- set the bar color
740 local Red, Green, Blue, Alpha
741 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player].FailedColor)
742 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetStatusBarColor( Red, Green, Blue, Alpha )
743  
744 -- hide the spark, we dont need it anymore
745 getglobal("eCastingBar"..fraFrame.."Spark"):Hide( )
746  
747 -- was the called event: spell failed?
748 if ( event == "SPELLCAST_FAILED" ) then
749  
750 -- yes, set the text accordingly
751 getglobal("eCastingBar"..fraFrame.."Text"):SetText( FAILED )
752  
753 else
754  
755 -- no, it must have been interupted instead, set the text accordingly
756 getglobal("eCastingBar"..fraFrame.."Text"):SetText( INTERRUPTED )
757  
758 end
759  
760 -- end the casting state, start the fadeout state
761 getglobal("eCastingBar"..fraFrame).casting = nil
762 getglobal("eCastingBar"..fraFrame).delay = 0
763 getglobal("eCastingBar"..fraFrame).fadeOut = 1
764 getglobal("eCastingBar"..fraFrame).holdTime = GetTime() + CASTING_BAR_HOLD_TIME
765 end
766  
767 end
768  
769 --[[ Handles the SPELLCAST_DELAYED event. ]]--
770 function eCastingBar_SpellcastDelayed( fraFrame, intDisruptionTime )
771  
772 -- is the bar still shown? ( not sure what the difference between this and :IsVisiable, but there is (figure it out!) )
773 if( getglobal("eCastingBar"..fraFrame):IsShown( ) ) then
774  
775 -- set the start and max time according to how much it was disrupted
776 getglobal("eCastingBar"..fraFrame).startTime = getglobal("eCastingBar"..fraFrame).startTime + ( intDisruptionTime / 1000 )
777 getglobal("eCastingBar"..fraFrame).maxValue = getglobal("eCastingBar"..fraFrame).maxValue + ( intDisruptionTime / 1000 )
778  
779 -- set the bar accordingly (basicly stricking it according to how much it was disrupted)
780 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetMinMaxValues( getglobal("eCastingBar"..fraFrame).startTime, getglobal("eCastingBar"..fraFrame).maxValue )
781  
782 if (getglobal("eCastingBar"..fraFrame).delay == nil) then
783 getglobal("eCastingBar"..fraFrame).delay = 0
784 end
785  
786 getglobal("eCastingBar"..fraFrame).delay = getglobal("eCastingBar"..fraFrame).delay + (intDisruptionTime / 1000)
787  
788 end
789  
790 end
791  
792 --[[ Handles the SPELLCAST_CHANNEL_START event. ]]--
793 function eCastingBar_SpellcastChannelStart( fraFrame, intDuration, strSpellName )
794 local Red, Green, Blue, Alpha
795 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player].ChannelColor)
796 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetStatusBarColor( Red, Green, Blue, Alpha )
797 -- show the spark
798 getglobal("eCastingBar"..fraFrame.."Spark"):Show( )
799  
800 -- set the bar to max
801 getglobal("eCastingBar"..fraFrame).maxValue = 1
802  
803 -- set the delay
804 getglobal("eCastingBar"..fraFrame).delay = 0
805  
806 -- set the start and end times
807 getglobal("eCastingBar"..fraFrame).startTime = GetTime( )
808 getglobal("eCastingBar"..fraFrame).initStartTime = GetTime( )
809  
810 -- if the duration is nil set it to 10 minutes. Nothing should last this long
811 if (intDuration == nil) then
812 intDuration = 600000
813 end
814 getglobal("eCastingBar"..fraFrame).endTime = getglobal("eCastingBar"..fraFrame).startTime + ( intDuration / 1000 )
815  
816 -- set the bar minium and maxium values
817 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetMinMaxValues( getglobal("eCastingBar"..fraFrame).startTime, getglobal("eCastingBar"..fraFrame).endTime )
818  
819 -- set the bar length visually to reflex the new time
820 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetValue( getglobal("eCastingBar"..fraFrame).endTime )
821  
822 -- set the text to the spell name
823 -- figure out how much to show
824 if ( eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"] == -1 ) then
825 -- show all
826 getglobal("eCastingBar"..fraFrame.."Text"):SetText( strSpellName )
827 elseif ( eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"] == 0) then
828 -- dont show it
829 getglobal("eCastingBar"..fraFrame.."Text"):SetText( "" )
830 else
831 -- if the size of the name is less than or equal to the max size, just show it all
832 if ( string.len(strSpellName) <= eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"] ) then
833 getglobal("eCastingBar"..fraFrame.."Text"):SetText( strSpellName )
834 else
835 getglobal("eCastingBar"..fraFrame.."Text"):SetText( string.sub(strSpellName , 1, eCastingBar_Saved[eCastingBar_Player][fraFrame.."SpellLength"]) )
836 end
837 end
838  
839 -- set the bar to fully opaque
840 getglobal("eCastingBar"..fraFrame):SetAlpha( 1.0 )
841  
842 -- reset various valuses used to hide the bar, also make sure its channeling not casting
843 getglobal("eCastingBar"..fraFrame).holdTime = 0
844 getglobal("eCastingBar"..fraFrame).casting = nil
845 getglobal("eCastingBar"..fraFrame).channeling = 1
846 getglobal("eCastingBar"..fraFrame).fadeOut = nil
847 getglobal("eCastingBar"..fraFrame):Show( )
848 getglobal("eCastingBar"..fraFrame).mode = "channeling"
849  
850 end
851  
852 --[[ Handles the SPELLCAST_CHANNEL_UPDATE event. ]]--
853 function eCastingBar_SpellcastChannelUpdate( fraFrame, intRemainingDuration )
854  
855 -- is the remaining time zero?
856 if( intRemainingDuration == 0 ) then
857  
858 -- yes, we aren't channeling anymore
859 getglobal("eCastingBar"..fraFrame).channeling = nil
860  
861 -- no, is the bar still shown? ( not sure what the difference between this and :IsVisiable, but there is (figure it out!) )
862 elseif( getglobal("eCastingBar"..fraFrame):IsShown( ) ) then
863  
864 -- set the original duration
865 local intOriginalDuration = getglobal("eCastingBar"..fraFrame).endTime - getglobal("eCastingBar"..fraFrame).startTime
866  
867 -- set the delay
868 local elapsedTime = GetTime() - getglobal("eCastingBar"..fraFrame).startTime;
869 local losttime = intOriginalDuration*1000 - elapsedTime*1000 - arg1;
870 getglobal("eCastingBar"..fraFrame).delay = getglobal("eCastingBar"..fraFrame).delay + (losttime / 1000);
871  
872 -- set the start and end time
873 getglobal("eCastingBar"..fraFrame).endTime = GetTime( ) + ( intRemainingDuration / 1000 )
874 getglobal("eCastingBar"..fraFrame).startTime = getglobal("eCastingBar"..fraFrame).endTime - intOriginalDuration
875  
876 -- set the bar length reflect the new state (basicly decreases the start time as time passes, thus shrinking the bar)
877 getglobal("eCastingBar"..fraFrame.."StatusBar"):SetMinMaxValues( getglobal("eCastingBar"..fraFrame).startTime, getglobal("eCastingBar"..fraFrame).endTime )
878  
879 -- test to see visually when it fires... and it doesn't fire much.
880 --ECB_addChat( "SPELLCAST_CHANNELING_UPDATE" )
881  
882 end
883  
884 end
885  
886 --[[ Handles all updates. ]]--
887 function eCastingBar_OnUpdate( frame )
888  
889 -- check if we were on a taxi.
890 -- Added for FlightMap support
891 if ( getglobal("eCastingBar"..frame).OnTaxi ) then
892 if (not getglobal("eCastingBar"..frame).flying) then
893 if UnitOnTaxi("player") then getglobal("eCastingBar"..frame).flying = true; end
894 return;
895 end
896  
897 -- are we on a taxi?
898 -- Did we just get off?
899 if (not UnitOnTaxi("player")) then
900 getglobal("eCastingBar"..frame).flying = nil
901 eCastingBar_SpellcastStop( "" )
902 end
903 end
904  
905 -- are we casting?
906 if( getglobal("eCastingBar"..frame).casting ) then
907 -- yes:
908 local intCurrentTime = GetTime()
909 local intSparkPosition = 0
910  
911 -- update the casting time
912 --eCastingBar_Time:SetText( string.sub( math.max( eCastingBar.maxValue - intCurrentTime, 0.00 ), 1,4 ) )
913  
914 -- Thanks to wbb at Cursed for the lovely formating
915 if ( eCastingBar_Saved[eCastingBar_Player][frame.."ShowTime"] == 1) then
916 getglobal("eCastingBar"..frame.."_Time"):SetText( string.format( "%.1f", math.max( getglobal("eCastingBar"..frame).maxValue - intCurrentTime, 0.0 ) ) )
917 else
918 getglobal("eCastingBar"..frame.."_Time"):SetText("")
919 end
920  
921 local bDelay = false
922  
923 if ( eCastingBar_Saved[eCastingBar_Player][frame.."ShowDelay"] == 1) then
924 if (getglobal("eCastingBar"..frame).delay ~= 0) then
925 bDelay = true
926 end
927 end
928  
929 if (bDelay) then
930 getglobal("eCastingBar"..frame.."_Delay"):SetText("+"..string.format( "%.1f", eCastingBar.delay ) )
931 else
932 getglobal("eCastingBar"..frame.."_Delay"):SetText("")
933 end
934  
935 -- is the status > than the max?
936 if( intCurrentTime > getglobal("eCastingBar"..frame).maxValue ) then
937  
938 -- yes, set it to max (not sure how it would get that way, but again blizzard is safe)
939 intCurrentTime = getglobal("eCastingBar"..frame).maxValue
940  
941 end
942  
943 -- update the bar length
944 getglobal("eCastingBar"..frame.."StatusBar"):SetValue( intCurrentTime )
945  
946 --reset the flash to hidden
947 getglobal("eCastingBar"..frame.."Flash"):Hide( )
948  
949 -- updates the spark
950 local width = getglobal("eCastingBar"..frame.."StatusBar"):GetWidth()
951 intSparkPosition = ( ( intCurrentTime - getglobal("eCastingBar"..frame).startTime ) / ( getglobal("eCastingBar"..frame).maxValue - getglobal("eCastingBar"..frame).startTime ) ) * width
952 if( intSparkPosition < 0 ) then
953 intSparkPosition = 0
954 end
955  
956 -- set the spark to the end of the current barsize
957 getglobal("eCastingBar"..frame.."Spark"):SetPoint( "CENTER", "eCastingBarStatusBar", "LEFT", intSparkPosition, 0 )
958  
959 -- no, are we channeling?
960 elseif ( getglobal("eCastingBar"..frame).channeling ) then
961  
962 -- yes:
963 local intTimeLeft = GetTime( )
964 local intBarValue = 0
965 local intSparkPosition = getglobal("eCastingBar"..frame).endTime
966  
967 -- update the channeling time
968 --eCastingBar_Time:SetText( string.sub( math.max( eCastingBar.endTime - intTimeLeft, 0.00 ), 1 , 4 ) )
969  
970 -- Thanks to wbb at Cursed for the lovely formating
971 if (eCastingBar_Saved[eCastingBar_Player][frame.."ShowTime"] == 1) then
972 -- if we are over 1 minute, do minute:seconds
973 local timeLeft = math.max( getglobal("eCastingBar"..frame).endTime - intTimeLeft, 0.0 )
974 local timeMsg = nil
975  
976 local minutes = 0
977 local seconds = 0
978  
979 if (timeLeft > 60) then
980 minutes = math.floor( ( timeLeft / 60 ))
981 local seconds = math.ceil( timeLeft - ( 60 * minutes ))
982  
983 if (seconds == 60) then
984 minutes = minutes + 1
985 seconds = 0
986 end
987 timeMsg = format("%s:%s", minutes, getFormattedNumber(seconds))
988 else
989 timeMsg = string.format( "%.1f", timeLeft )
990 end
991  
992 --format(COOLDOWNCOUNT_MINUTES_SECONDS_FORMAT, minutes, CooldownCount_GetFormattedNumber(seconds))
993 getglobal("eCastingBar"..frame.."_Time"):SetText( timeMsg )
994 else
995 getglobal("eCastingBar"..frame.."_Time"):SetText("")
996 end
997  
998 local bDelay = false
999  
1000 if (eCastingBar_Saved[eCastingBar_Player][frame.."ShowDelay"] == 1) then
1001 if (getglobal("eCastingBar"..frame).delay ~= 0) then
1002 bDelay = true
1003 end
1004 end
1005  
1006 if (bDelay) then
1007 getglobal("eCastingBar"..frame.."_Delay"):SetText("-"..string.format( "%.1f", eCastingBar.delay ) )
1008 else
1009 getglobal("eCastingBar"..frame.."_Delay"):SetText("")
1010 end
1011  
1012 -- is the time left greater than channeling end time?
1013 if( intTimeLeft > getglobal("eCastingBar"..frame).endTime ) then
1014  
1015 -- yes, set it to the channeling end time (this will happen if you get delayed longer than the time left on channeling)
1016 intTimeLeft = getglobal("eCastingBar"..frame).endTime
1017  
1018 end
1019  
1020 -- are the times equal?
1021 if( intTimeLeft == getglobal("eCastingBar"..frame).endTime ) then
1022  
1023 -- yes, we finished channeling, so start the fadeout process and exit
1024 getglobal("eCastingBar"..frame).channeling = nil
1025 getglobal("eCastingBar"..frame).fadeOut = 1
1026 return
1027  
1028 end
1029  
1030 -- update the bar length
1031 intBarValue = getglobal("eCastingBar"..frame).startTime + ( getglobal("eCastingBar"..frame).endTime - intTimeLeft )
1032 getglobal("eCastingBar"..frame.."StatusBar"):SetValue( intBarValue )
1033  
1034 --reset the flash to hidden
1035 getglobal("eCastingBar"..frame.."Flash"):Hide( )
1036  
1037 -- updates the spark
1038 local width = getglobal("eCastingBar"..frame.."Background"):GetWidth()
1039 intSparkPosition = ( ( intBarValue - getglobal("eCastingBar"..frame).startTime ) / ( getglobal("eCastingBar"..frame).endTime - getglobal("eCastingBar"..frame).startTime ) ) * width
1040 getglobal("eCastingBar"..frame.."Spark"):SetPoint( "CENTER", "eCastingBar"..frame.."StatusBar", "LEFT", intSparkPosition, 0 )
1041  
1042 -- no, is the current time < the hold time?
1043 elseif( GetTime( ) < getglobal("eCastingBar"..frame).holdTime ) then
1044  
1045 -- yes, exit, we aren't doing anything
1046 return
1047  
1048 -- no, are we in flash mode?
1049 elseif( getglobal("eCastingBar"..frame).flash ) then
1050  
1051 -- yes, sest the flash alpha
1052 local intAlpha = getglobal("eCastingBar"..frame.."Flash"):GetAlpha( ) + CASTING_BAR_FLASH_STEP
1053  
1054 -- reset the text
1055 getglobal("eCastingBar"..frame.."_Time"):SetText( "" )
1056  
1057 -- is the flash alpha < 1?
1058 if( intAlpha < 1 ) then
1059  
1060 -- yes, step it up
1061 getglobal("eCastingBar"..frame.."Flash"):SetAlpha( intAlpha )
1062  
1063 else
1064  
1065 -- no, which means its 1 or greater, and we are at full alpha and done.
1066 getglobal("eCastingBar"..frame).flash = nil
1067  
1068 end
1069  
1070 -- no, are we fading out now?
1071 elseif ( getglobal("eCastingBar"..frame).fadeOut ) then
1072  
1073 --yes, set the CastingBar alpha
1074 local intAlpha = getglobal("eCastingBar"..frame):GetAlpha( ) - CASTING_BAR_ALPHA_STEP
1075  
1076 -- is the bar alpha > 0?
1077 if( intAlpha > 0 ) then
1078  
1079 -- step it down
1080 getglobal("eCastingBar"..frame):SetAlpha( intAlpha )
1081  
1082 else
1083  
1084 -- no, which means its 0 or larger, and we are at fully transparent so we are done and hide the bar.
1085 getglobal("eCastingBar"..frame).fadeOut = nil
1086 getglobal("eCastingBar"..frame):Hide( )
1087  
1088 end
1089 end
1090 end
1091  
1092 function getFormattedNumber(number)
1093 if (strlen(number) < 2 ) then
1094 return "0"..number
1095 else
1096 return number
1097 end
1098 end
1099  
1100 --[[ Starts moving the frame. ]]--
1101 function eCastingBar_MouseUp( strButton, frmFrame, frameType )
1102  
1103 if( eCastingBar_Saved[eCastingBar_Player][frameType.."Locked"] == 0 ) then
1104 getglobal( frmFrame ):StopMovingOrSizing( )
1105 eCastingBar_Saved[eCastingBar_Player][frameType.."Left"] = getglobal(frmFrame):GetLeft()
1106 eCastingBar_Saved[eCastingBar_Player][frameType.."Bottom"] = getglobal(frmFrame):GetBottom()
1107  
1108 getglobal("eCastingBar"..frameType.."LeftSlider"):SetValue(eCastingBar_Saved[eCastingBar_Player][frameType.."Left"])
1109 getglobal("eCastingBar"..frameType.."BottomSlider"):SetValue(eCastingBar_Saved[eCastingBar_Player][frameType.."Bottom"])
1110 end
1111 end
1112  
1113 --[[ Stops moving the frame. ]]--
1114 function eCastingBar_MouseDown( strButton, frmFrame, frameType )
1115 if( strButton == "LeftButton" and (eCastingBar_Saved[eCastingBar_Player][frameType.."Locked"] == 0 ) ) then
1116 getglobal( frmFrame ):StartMoving( )
1117 end
1118 end
1119  
1120 function eCastingBarGeneral_MouseUp( strButton, frmFrame )
1121 getglobal( frmFrame ):StopMovingOrSizing( )
1122 end
1123  
1124 --[[ Stops moving the frame. ]]--
1125 function eCastingBarGeneral_MouseDown( strButton, frmFrame, frameType )
1126 if( strButton == "LeftButton") then
1127 getglobal( frmFrame ):StartMoving( )
1128 end
1129 end
1130  
1131 function eCastingBar_getShowDelay()
1132 return eCastingBar_Saved[eCastingBar_Player].ShowDelay
1133 end
1134  
1135 function eCastingBar_setShowDelay( intShowDelay )
1136 eCastingBar_Saved[eCastingBar_Player].ShowDelay = intShowDelay
1137 end
1138  
1139 function eCastingBar_checkBorders()
1140  
1141 for index, option in frameSuffixes do
1142 if (eCastingBar_Saved[eCastingBar_Player][option.."HideBorder"] == 1) then
1143 getglobal("eCastingBar"..option):SetBackdrop(nil)
1144 else
1145 getglobal("eCastingBar"..option):SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }})
1146 getglobal("eCastingBar"..option):SetBackdropColor(0,0,0,0.5)
1147 end
1148 end
1149  
1150 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
1151 if (eCastingBar_Saved[eCastingBar_Player].MirrorHideBorder == 1) then
1152 getglobal("eCastingBarMirror"..index):SetBackdrop(nil)
1153 else
1154 getglobal("eCastingBarMirror"..index):SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 5, right = 5, top = 5, bottom = 5 }})
1155 getglobal("eCastingBarMirror"..index):SetBackdropColor(0,0,0,0.5)
1156 end
1157 end
1158 end
1159  
1160 --[[-------------------------------------------
1161 Functions for Locked State
1162 -------------------------------------------]]--
1163  
1164 function eCastingBar_checkLocked()
1165 for index, option in frameSuffixes do
1166 -- only show the outline if we are enabled
1167 if (eCastingBar_Saved[eCastingBar_Player][option.."Enabled"] == 1 and
1168 eCastingBar_Saved[eCastingBar_Player][option.."Locked"] == 0) then
1169 getglobal("eCastingBar"..option.."_Outline"):Show()
1170 else
1171 getglobal("eCastingBar"..option.."_Outline"):Hide()
1172 end
1173 end
1174  
1175 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
1176 -- only show the outline if we are enabled
1177 if (eCastingBar_Saved[eCastingBar_Player].MirrorEnabled == 1 and
1178 eCastingBar_Saved[eCastingBar_Player].MirrorLocked == 0) then
1179 getglobal("eCastingBarMirror_Outline"):Show()
1180 else
1181 getglobal("eCastingBarMirror_Outline"):Hide()
1182 end
1183 end
1184 end
1185  
1186  
1187 --[[-------------------------------------------
1188 Functions for Enabled State
1189 -------------------------------------------]]--
1190  
1191 --[[ Disables the frame. ]]--
1192 function eCastingBar_Disable( fraFrame )
1193 eCastingBar_Saved[eCastingBar_Player][fraFrame.."Enabled"] = 0
1194  
1195 local intIndex = 0
1196 local strEvent = ""
1197  
1198 -- for each border in eCastingBar__Events register event.
1199 if (fraFrame == "") then
1200 for intIndex, strEvent in eCastingBar__Events do
1201  
1202 -- make sure old casting bar is registered
1203 eCastingBar_Register( "CastingBarFrame", strEvent )
1204  
1205 -- now unregister our casting bar
1206 eCastingBar_Unregister( "eCastingBar", strEvent )
1207  
1208 end
1209  
1210 -- CastTime mod exist
1211 if( CastTimeFrame ) then
1212  
1213 -- for each event in eCastingBar__CastTimeEvents register event.
1214 for intIndex, strEvent in eCastingBar__CastTimeEvents do
1215  
1216 -- make sure CastTime mod is enabled also bar is registered
1217 eCastingBar_Register( "CastTimeFrame", strEvent )
1218  
1219 end
1220  
1221 end
1222 end
1223  
1224 -- is the frame unlocked?
1225 if( eCastingBar_Saved[eCastingBar_Player][fraFrame.."Locked"] == 0 ) then
1226  
1227 -- yes, lets hide the outline
1228 getglobal("eCastingBar"..fraFrame.."_Outline"):Hide( )
1229  
1230 end
1231  
1232  
1233  
1234 -- Check for FlightMap
1235 if (FlightMapFrame) then
1236 if (eCastingBar_Saved[eCastingBar_Player].FlightMapX and eCastingBar_Saved[eCastingBar_Player].FlightMapY) then
1237 FlightMapTimesFrame:ClearAllPoints()
1238 FlightMapTimesFrame:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", eCastingBar_Saved[eCastingBar_Player].FlightMapX, eCastingBar_Saved[eCastingBar_Player].FlightMapY )
1239 end
1240 end
1241 end
1242  
1243 --[[ Enables the frame. ]]--
1244 function eCastingBar_Enable( fraFrame )
1245 eCastingBar_Saved[eCastingBar_Player][fraFrame.."Enabled"] = 1
1246  
1247 local intIndex = 0
1248 local strEvent = ""
1249  
1250 if (fraFrame == "") then
1251 -- for each border in eCastingBar__Events register event.
1252 for intIndex, strEvent in eCastingBar__Events do
1253  
1254 -- make sure our bar is registered
1255 eCastingBar_Register( "eCastingBar", strEvent )
1256  
1257 -- now unregister blizzard bar
1258 eCastingBar_Unregister( "CastingBarFrame", strEvent )
1259  
1260 end
1261  
1262 -- CastTime mod exist
1263 if( CastTimeFrame ) then
1264  
1265 -- for each event in eCastingBar__CastTimeEvents register event.
1266 for intIndex, strEvent in eCastingBar__CastTimeEvents do
1267  
1268 -- make sure CastTime mod is enabled also bar is registered
1269 eCastingBar_Unregister( "CastTimeFrame", strEvent )
1270  
1271 end
1272  
1273 end
1274 end
1275  
1276 -- is the frame unlocked?
1277 if( eCastingBar_Saved[eCastingBar_Player][fraFrame.."Locked"] == 0 ) then
1278  
1279 -- yes, lets show the outline
1280 getglobal("eCastingBar"..fraFrame.."_Outline"):Show( )
1281  
1282 end
1283 end
1284  
1285 --[[ Toggle enabled state. ]]--
1286 function eCastingBar_checkEnabled()
1287 for index, option in frameSuffixes do
1288 if (eCastingBar_Saved[eCastingBar_Player][option.."Enabled"] == 1) then
1289 eCastingBar_Enable(option, 1)
1290 else
1291 eCastingBar_Disable(option, 0)
1292 end
1293 end
1294  
1295 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
1296 if (eCastingBar_Saved[eCastingBar_Player].MirrorEnabled == 1) then
1297 if( eCastingBar_Saved[eCastingBar_Player].MirrorLocked == 0 ) then
1298 -- yes, lets show the outline
1299 getglobal("eCastingBarMirror_Outline"):Show()
1300 end
1301 else
1302 if( eCastingBar_Saved[eCastingBar_Player].MirrorLocked == 0 ) then
1303 -- yes, lets hide the outline
1304 getglobal("eCastingBarMirror_Outline"):Hide()
1305 end
1306 end
1307 end
1308 end
1309  
1310  
1311 --[[-------------------------------------------
1312 Functions for using the Texture
1313 -------------------------------------------]]--
1314  
1315 --[[ Toggle enabled state. ]]--
1316 function eCastingBar_checkTextures()
1317  
1318 for index, option in frameSuffixes do
1319 if ( eCastingBar_Saved[eCastingBar_Player][option.."UsePerlTexture"] == 1) then
1320 getglobal("eCastingBar"..option.."Texture"):SetTexture( CASTING_BAR_PERL_TEXTURE )
1321 else
1322 getglobal("eCastingBar"..option.."Texture"):SetTexture( CASTING_BAR_DEFAULT_TEXTURE )
1323 end
1324  
1325 getglobal("eCastingBar"..option.."Texture"):SetWidth(20)
1326 getglobal("eCastingBar"..option.."Texture"):SetHeight(10)
1327  
1328 end
1329  
1330 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
1331 if ( eCastingBar_Saved[eCastingBar_Player].MirrorUsePerlTexture == 1) then
1332 getglobal("eCastingBarMirror"..index.."StatusBarTexture"):SetTexture( CASTING_BAR_PERL_TEXTURE )
1333 else
1334 getglobal("eCastingBarMirror"..index.."StatusBarTexture"):SetTexture( CASTING_BAR_DEFAULT_TEXTURE )
1335 end
1336  
1337 getglobal("eCastingBarMirror"..index.."StatusBarTexture"):SetWidth(20)
1338 getglobal("eCastingBarMirror"..index.."StatusBarTexture"):SetHeight(10)
1339 end
1340  
1341 end
1342  
1343  
1344 function eCastingBar_checkTimeColors()
1345 local Red, Green, Blue, Alpha
1346  
1347 for index, option in frameSuffixes do
1348 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player][option.."TimeColor"])
1349 getglobal("eCastingBar"..option.."_Time"):SetTextColor(Red,Green,Blue, Alpha )
1350 end
1351  
1352 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player].MirrorTimeColor)
1353  
1354 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
1355 getglobal("eCastingBarMirror"..index.."StatusBar_Time"):SetTextColor(Red,Green,Blue, Alpha )
1356 end
1357 end
1358  
1359 function eCastingBar_setDelayColor()
1360 local Red, Green, Blue, Alpha
1361 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player].DelayColor)
1362 eCastingBar_Delay:SetTextColor(Red,Green,Blue, Alpha )
1363 end
1364  
1365 --[[ sets up the flash to look cool ]]--
1366 -- (thanks goes to kaitlin for the code used while resting).
1367 function eCastingBar_checkFlashBorderColors()
1368  
1369 local frmFrame = "eCastingBarFlash"
1370 local intIndex = 0
1371 local strBorder = ""
1372  
1373 local Red, Green, Blue, Alpha
1374  
1375 for index, option in frameSuffixes do
1376 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player][option.."FlashBorderColor"])
1377  
1378 -- for each border in eCastingBar__FlashBorders set the color to gold.
1379 for intIndex, strBorder in eCastingBar__FlashBorders do
1380 getglobal( "eCastingBar"..option.."Flash_"..strBorder ):SetVertexColor( Red, Green, Blue, Alpha )
1381 end
1382 end
1383  
1384 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
1385 Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[eCastingBar_Player].MirrorFlashBorderColor)
1386 for intIndex, strBorder in eCastingBar__FlashBorders do
1387 getglobal( "eCastingBarMirror"..index.."Flash_"..strBorder ):SetVertexColor( Red, Green, Blue, Alpha )
1388 end
1389 end
1390 end
1391  
1392  
1393 -- Sets the width and height of the casting bar
1394 function eCastingBar_SetSize()
1395 local width, height, bottom, left, bar
1396  
1397 for index, option in frameSuffixes do
1398 -- check boundaries
1399 if (eCastingBar_Saved[eCastingBar_Player][option.."Width"] < CASTING_BAR_SLIDER_WIDTH_MIN) then
1400 width = CASTING_BAR_SLIDER_WIDTH_MIN
1401 elseif (eCastingBar_Saved[eCastingBar_Player][option.."Width"] > CASTING_BAR_SLIDER_WIDTH_MAX ) then
1402 width = CASTING_BAR_SLIDER_WIDTH_MAX
1403 else
1404 width = eCastingBar_Saved[eCastingBar_Player][option.."Width"]
1405 end
1406  
1407 if (eCastingBar_Saved[eCastingBar_Player][option.."Height"] > CASTING_BAR_SLIDER_HEIGHT_MAX) then
1408 height = CASTING_BAR_SLIDER_HEIGHT_MAX
1409 elseif (eCastingBar_Saved[eCastingBar_Player][option.."Height"] < CASTING_BAR_SLIDER_HEIGHT_MIN ) then
1410 height = CASTING_BAR_SLIDER_HEIGHT_MIN
1411 else
1412 height = eCastingBar_Saved[eCastingBar_Player][option.."Height"]
1413 end
1414  
1415 --if (eCastingBar_Saved[eCastingBar_Player][option.."Left"] < 0) then
1416 -- left = 0
1417 --else
1418 left = eCastingBar_Saved[eCastingBar_Player][option.."Left"]
1419 --end
1420  
1421  
1422 --if (eCastingBar_Saved[eCastingBar_Player][option.."Bottom"] < 0 ) then
1423 -- bottom = 0
1424 --else
1425 bottom = eCastingBar_Saved[eCastingBar_Player][option.."Bottom"]
1426 --end
1427  
1428 getglobal("eCastingBar"..option):SetWidth(width)
1429 getglobal("eCastingBar"..option):SetHeight(height)
1430  
1431 getglobal("eCastingBar"..option.."Background"):SetWidth(width - 9)
1432 getglobal("eCastingBar"..option.."Background"):SetHeight(height - 8)
1433  
1434 getglobal("eCastingBar"..option.."Flash"):SetWidth(width)
1435 getglobal("eCastingBar"..option.."Flash"):SetHeight(height)
1436  
1437 getglobal("eCastingBar"..option.."StatusBar"):SetWidth(width - 9)
1438 getglobal("eCastingBar"..option.."StatusBar"):SetHeight(height - 10)
1439  
1440 getglobal("eCastingBar"..option.."_Outline"):SetWidth(width)
1441 getglobal("eCastingBar"..option.."_Outline"):SetHeight(height)
1442 getglobal("eCastingBar"..option.."_Outline"):ClearAllPoints()
1443 getglobal("eCastingBar"..option.."_Outline"):SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left, bottom )
1444  
1445  
1446  
1447 getglobal("eCastingBar"..option.."Flash_TOP"):SetWidth(width - 24)
1448 getglobal("eCastingBar"..option.."Flash_BOTTOM"):SetWidth(width - 24)
1449 getglobal("eCastingBar"..option.."Flash_LEFT"):SetHeight(height - 24)
1450 getglobal("eCastingBar"..option.."Flash_RIGHT"):SetHeight(height - 24)
1451  
1452 getglobal("eCastingBar"..option.."Spark"):SetHeight(height + 13)
1453  
1454 getglobal("eCastingBar"..option.."Text"):SetWidth(width - 49)
1455 getglobal("eCastingBar"..option.."Text"):SetHeight(height + 13)
1456  
1457 -- set the font size
1458 eCastingBarText:SetTextHeight(eCastingBar_Saved[eCastingBar_Player][option.."FontSize"])
1459 eCastingBar_Time:SetTextHeight(eCastingBar_Saved[eCastingBar_Player][option.."FontSize"])
1460 end
1461  
1462 for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
1463  
1464 -- check boundaries
1465 if (eCastingBar_Saved[eCastingBar_Player].MirrorWidth < CASTING_BAR_SLIDER_WIDTH_MIN) then
1466 width = CASTING_BAR_SLIDER_WIDTH_MIN
1467 elseif (eCastingBar_Saved[eCastingBar_Player].MirrorWidth > CASTING_BAR_SLIDER_WIDTH_MAX ) then
1468 width = CASTING_BAR_SLIDER_WIDTH_MAX
1469 else
1470 width = eCastingBar_Saved[eCastingBar_Player].MirrorWidth
1471 end
1472  
1473 if (eCastingBar_Saved[eCastingBar_Player].MirrorHeight > CASTING_BAR_SLIDER_HEIGHT_MAX) then
1474 height = CASTING_BAR_SLIDER_HEIGHT_MAX
1475 elseif (eCastingBar_Saved[eCastingBar_Player].MirrorHeight < CASTING_BAR_SLIDER_HEIGHT_MIN ) then
1476 height = CASTING_BAR_SLIDER_HEIGHT_MIN
1477 else
1478 height = eCastingBar_Saved[eCastingBar_Player].MirrorHeight
1479 end
1480  
1481 --if (eCastingBar_Saved[eCastingBar_Player].MirrorLeft < 0) then
1482 -- left = 0
1483 --else
1484 left = eCastingBar_Saved[eCastingBar_Player].MirrorLeft
1485 --end
1486  
1487  
1488 --if (eCastingBar_Saved[eCastingBar_Player].MirrorBottom < 0 ) then
1489 -- bottom = 0
1490 --else
1491 bottom = eCastingBar_Saved[eCastingBar_Player].MirrorBottom
1492 --end
1493  
1494 getglobal("eCastingBarMirror"..index):SetWidth(width)
1495 getglobal("eCastingBarMirror"..index):SetHeight(height)
1496  
1497 getglobal("eCastingBarMirror"..index.."Background"):SetWidth(width - 9)
1498 getglobal("eCastingBarMirror"..index.."Background"):SetHeight(height - 8)
1499  
1500 getglobal("eCastingBarMirror"..index.."Flash"):SetWidth(width)
1501 getglobal("eCastingBarMirror"..index.."Flash"):SetHeight(height)
1502  
1503 getglobal("eCastingBarMirror"..index.."StatusBar"):SetWidth(width - 9)
1504 getglobal("eCastingBarMirror"..index.."StatusBar"):SetHeight(height - 10)
1505  
1506 getglobal("eCastingBarMirror_Outline"):SetWidth(width)
1507 getglobal("eCastingBarMirror_Outline"):SetHeight(height)
1508 getglobal("eCastingBarMirror_Outline"):ClearAllPoints()
1509 getglobal("eCastingBarMirror_Outline"):SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left, bottom )
1510  
1511  
1512 getglobal("eCastingBarMirror"..index.."Flash_TOP"):SetWidth(width - 24)
1513 getglobal("eCastingBarMirror"..index.."Flash_BOTTOM"):SetWidth(width - 24)
1514 getglobal("eCastingBarMirror"..index.."Flash_LEFT"):SetHeight(height - 24)
1515 getglobal("eCastingBarMirror"..index.."Flash_RIGHT"):SetHeight(height - 24)
1516  
1517 getglobal("eCastingBarMirror"..index.."StatusBarSpark"):SetHeight(height + 13)
1518  
1519 getglobal("eCastingBarMirror"..index.."StatusBarText"):SetWidth(width - 49)
1520 getglobal("eCastingBarMirror"..index.."StatusBarText"):SetHeight(height + 13)
1521  
1522 -- set the font size
1523 getglobal("eCastingBarMirror"..index.."StatusBarText"):SetTextHeight(eCastingBar_Saved[eCastingBar_Player].MirrorFontSize)
1524 getglobal("eCastingBarMirror"..index.."StatusBar_Time"):SetTextHeight(eCastingBar_Saved[eCastingBar_Player].MirrorFontSize)
1525 end
1526 end
1527  
1528  
1529  
1530  
1531 function eCastingBar_Copy_Table(src, dest)
1532 for index, value in src do
1533 if (type(value) == "table") then
1534 dest[index] = {};
1535 eCastingBar_Copy_Table(value, dest[index]);
1536 else
1537 dest[index] = value;
1538 end
1539 end
1540 end
1541  
1542  
1543  
1544  
1545  
1546 ------------------- MIRROR -------------------
1547  
1548  
1549 function eCastingBarMirror_OnLoad()
1550 this:RegisterEvent("MIRROR_TIMER_PAUSE");
1551 this:RegisterEvent("MIRROR_TIMER_STOP");
1552 this:RegisterEvent("PLAYER_ENTERING_WORLD");
1553 this.timer = nil;
1554 end