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