Quantcast eCastingBar - WoWInterface
Thread Tools Display Modes
04-25-18, 01:49 AM   #1
Voxxel
A Chromatic Dragonspawn
Join Date: Mar 2009
Posts: 169
eCastingBar

Hello!

My all-time favorite casting bar addon - Neuro's eCastingBar - I used since TBC (or vanilla?) has stopped working in BfA Beta. Could you help me to find out if this caused by a tiny bug that can be solved in minutes or this is something bigger, more complicated to fix?

Some error messages pop up as well, but since I'm completely green for lua coding, I don't really understand what does it mean.

The borders of the bars are showing as intended but the bar itself (the background texture and the font) does not.

when loaded with addon defaults:
Code:
Message: eCastingBar: Couldn't find relative frame: eCastingBarDragButton
Time: Wed Apr 25 09:38:52 2018
Count: 4
Code:
Message: Couldn't find frame parent: eCastingBarMenuControlTemplate
Time: Wed Apr 25 09:38:52 2018
Count: 4
When casting a spell:
Code:
Message: Interface\AddOns\eCastingBar\eCastingBar.lua:222: attempt to perform arithmetic on local 'endTime' (a boolean value)
Time: Wed Apr 25 09:42:48 2018
Count: 2
Stack: Interface\AddOns\eCastingBar\eCastingBar.lua:222: attempt to perform arithmetic on local 'endTime' (a boolean value)
Interface\AddOns\eCastingBar\eCastingBar.lua:222: in function `eCastingBar_OnEvent'
[string "*:OnEvent"]:1: in function <[string "*:OnEvent"]:1>

Locals: self = eCastingBar {
 0 = <userdata>
 startTime = 215631.021
 holdTime = 0
 frame = ""
 unit = "player"
}
newevent = "UNIT_SPELLCAST_START"
newarg1 = "player"
unit = "player"
name = "eCastingBar"
barIcon = eCastingBarStatusBarIcon {
 0 = <userdata>
}
barFlash = eCastingBarFlash {
 0 = <userdata>
}
barStatusBar = eCastingBarStatusBar {
 0 = <userdata>
}
barSpark = eCastingBarStatusBarSpark {
 0 = <userdata>
}
barText = eCastingBarStatusBarText {
 0 = <userdata>
}
frame = ""
spellName = "Swift Red Gryphon"
spellRank = "Swift Red Gryphon"
displayName = 132239
texture = 215629521
startTime = 215631021
endTime = false
isTradeSkill = "Cast-3-4028-1643-3671-32289-0002603176"
castID = false
notInterruptible = 32289
Red = 1
Green = 0.7
Blue = 0
Alpha = 1
(*temporary) = 215631.021
(*temporary) = eCastingBarStatusBarSpark {
 0 = <userdata>
}
(*temporary) = <userdata>
(*temporary) = 0.7
(*temporary) = 0
(*temporary) = 1
(*temporary) = "attempt to perform arithmetic on local 'endTime' (a boolean value)"
CASTING_BAR_BACKGROUND_FILE = "Interface\Tooltips\UI-Tooltip-Background"
CASTING_BAR_EDGE_FILE_UNINT = "Interface\DialogFrame\UI-DialogBox-Border"
CASTING_BAR_EDGE_FILE = "Interface\Tooltips\UI-Tooltip-Border"
  Reply With Quote
04-25-18, 02:53 AM   #2
d87
A Flamescale Wyrmkin
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 125
https://us.battle.net/forums/en/wow/topic/20762318007
Changes to UNIT_SPELLCAST_* events and UnitCastingInfo / UnitChannelInfo
probably just remove nameSubtext from these two functions results

Also Dominos castbar looks very similar to that, if you'll have to switch

Last edited by d87 : 04-25-18 at 03:02 AM.
  Reply With Quote
04-26-18, 02:15 AM   #3
Voxxel
A Chromatic Dragonspawn
Join Date: Mar 2009
Posts: 169
Thanks for the help, d87!

The BfA Addon Changes page says:
Function changes:
  • UnitCastingInfo - dropped second parameter (nameSubtext).
  • UnitChannelInfo - dropped second parameter (nameSubtext).

Event changes:
  • UNIT_SPELLCAST_SUCCEEDED - no longer provide spell name and rank.
  • UNIT_SPELLCAST_FAILED_QUIET - no longer provide spell name and rank.
  • UNIT_SPELLCAST_INTERRUPTED - no longer provide spell name and rank.
  • UNIT_SPELLCAST_START - no longer provide spell name and rank.
  • UNIT_SPELLCAST_FAILED - no longer provide spell name and rank.
  • UNIT_SPELLCAST_STOP - no longer provide spell name and rank.
  • UNIT_SPELLCAST_DELAYED - no longer provide spell name and rank.
  • UNIT_SPELLCAST_CHANNEL_START - no longer provide spell name and rank.
  • UNIT_SPELLCAST_CHANNEL_UPDATE - no longer provide spell name and rank.
  • UNIT_SPELLCAST_CHANNEL_STOP - no longer provide spell name and rank.
I'm nowhere to understand .lua but I tried to remove spellName and spellRank from locals at every UNIT_SPELLCAST_* but that didn't work. Also curious what nameSubtext means? This refers to the (unit) parameter in this code? (for example) :

Code:
function eCastingBar_OnEvent(self, newevent, ...)
	local newarg1 = ...;

	local unit = self.unit;
	if newevent == "PLAYER_ENTERING_WORLD" then
		self:Hide();
		local nameChannel  = UnitChannelInfo(unit);
		local nameSpell  = UnitCastingInfo(unit);
		if ( nameChannel ) then
			newevent = "UNIT_SPELLCAST_CHANNEL_START";
			newarg1 = unit;
		elseif ( nameSpell ) then
			newevent = "UNIT_SPELLCAST_START";
			newarg1 = unit;
		end
	end
	if ( newarg1 ~= unit ) then
		return;
	end
  Reply With Quote
04-26-18, 02:39 AM   #4
d87
A Flamescale Wyrmkin
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 125
find this line
Code:
if( newevent == "UNIT_SPELLCAST_START" ) then
		local spellName, spellRank, displayName, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(unit)
remove spellRank. it is the second parameter in this case (or nameSubtext)
also add 'local spellRank = "" ' after in case the addon was using it somehow

and same thing with two occurrences for UnitChannelInfo in CHANNEL_START and CHANNEL_UPDATE event handlers


but regarding the first two errors you mentioned i don't know and i don't have the beta

Last edited by d87 : 04-26-18 at 02:52 AM.
  Reply With Quote
04-26-18, 03:27 PM   #5
Voxxel
A Chromatic Dragonspawn
Join Date: Mar 2009
Posts: 169
Thanks a lot! When I set Spell Rank and Spell Name not to display in the addon options, the bars become functional so I can see empty cast bars at least.

Do you have any trick how to modify the code to actually display the spell name to know what spell my target / focus casts? If I turn on showing spell names in the options the addon goes unresponsive once again.

Last edited by Voxxel : 04-27-18 at 08:13 AM.
  Reply With Quote
05-06-18, 01:43 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Based on my reading of the Blizzard change thread, the spell name value was removed along with the spell rank. Without seeing the rest of the code (and I'm too lazy to go hunt the addon down and download it) I would guess something like this should work:

Old:

Code:
if( newevent == "UNIT_SPELLCAST_START" ) then
		local spellName, spellRank, displayName, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(unit)
The parts in red are no longer valid in WoW 8.x and need to be removed.

New, best option:

Code:
if( newevent == "UNIT_SPELLCAST_START" ) then
		local displayName, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(unit)
		local spellName, spellRank = displayName, ""
The parts in green are added. This just sets the "spellName" variable to copy the "displayName" value that (as far as I know) is still present. There are some spells where the text displayed on the default castbar isn't the actual name of the spell, like various opening and gathering actions; the "displayName" value is the text to be displayed. If you want to see the actual spell name, then try this instead:

New, second option:

Code:
if( newevent == "UNIT_SPELLCAST_START" ) then
		local displayName, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellID = UnitCastingInfo(unit)
		local spellName, spellRank = GetSpellInfo(spellID), ""
Again, the parts in green are added. UnitCastingInfo has returned a "spellID" value for quite a while now, so that isn't a new change for BFA, but we need to store it in order to use it on the next line, where we call the GetSpellInfo function to get the real name of the spell, and also set the "spellRank" value to an empty string just in case the addon is expecting it to exist.

Whichever solution you use, you'll need to apply the same solution everywhere that UnitCastingInfo or UnitChannelInfo is called.

Also, it might be obvious, but I'll say it anyway: these changes are not compatible with current live realms, so don't try to use the same version of the addon in both places.
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
05-21-18, 03:02 AM   #7
Voxxel
A Chromatic Dragonspawn
Join Date: Mar 2009
Posts: 169
I tried to modify the lua both ways, but it doesn't work either way, I think something is still missing. With the "new best option" the cast bar lit up just for a single second then suddenly vanish when I cast something, the "new second option" doesn't show anything at all.

The spellName and spellRank variables are in other parts of the lua too, not only in UNIT_SPELLCAST_* events. Maybe these should be changed too? I also have no idea if the UnitCastingInfo(*) and unitChannelInfo(*) parameters could cause any problem as you left them untouched in the examples.

Here's the modified lua. (spellName and spellRank variables can only be found up to ~ line 400). Would you please take a look what's missing?

Lua Code:
  1. -- Global constants
  2. CASTING_BAR_MAJOR_VERSION = "4";
  3. CASTING_BAR_MINOR_VERSION = "0";
  4. CASTING_BAR_REVISION = "1";
  5. CASTING_BAR_ALPHA_STEP = 0.05;
  6. CASTING_BAR_FLASH_STEP = 0.2;
  7. CASTING_BAR_HOLD_TIME = 1;
  8. CASTING_BAR_WIDTH = 264;
  9. CASTING_BAR_HEIGHT = 30;
  10. CASTING_BAR_LEFT = (GetScreenWidth()-CASTING_BAR_WIDTH)/2
  11. CASTING_BAR_SLIDER_WIDTH_MIN = 100;
  12. CASTING_BAR_SLIDER_WIDTH_MAX = 2000;
  13. CASTING_BAR_SLIDER_HEIGHT_MIN = 20;
  14. CASTING_BAR_SLIDER_HEIGHT_MAX = 60;
  15. CASTING_BAR_SPELL_JUSTIFY = "Center";
  16. CASTINGBAR_ICON_POSITION = {
  17.     { text = CASTINGBAR_LEFT_TEXT, value = "LEFT"},
  18.     { text = CASTINGBAR_RIGHT_TEXT, value = "RIGHT"},
  19.     { text = CASTINGBAR_HIDDEN_TEXT, value = "HIDDEN"}
  20. };
  21. CASTINGBAR_HEADER = strWhite.."eCastingBar v"..strGreen..CASTING_BAR_MAJOR_VERSION..strWhite.."."..strGreen..CASTING_BAR_MINOR_VERSION.."."..strGreen..CASTING_BAR_REVISION..strWhite;
  22. CASTINGBAR_HELP = {
  23.     strLine1 = strYellow.."--- "..CASTINGBAR_HEADER..strYellow.." --- ",
  24.     strLine2 = strWhite..strTab..CASTINGBAR_CHAT_C1..strYellow..CASTINGBAR_HELP_STRING..strWhite
  25. };
  26.  
  27. -- Global variables
  28. eCastingBar_Saved = {};
  29. eCastingBar_Resolution = nil;
  30. eCastingBar_ResolutionWidth = 0;
  31. eCastingBar_ResolutionHeight = 0;
  32. eCastingBar_MENU_SAVEDSETTINGS = nil;
  33. eCastingBar_SETTINGS_INDEX = "";
  34.  
  35. -- Local Constants
  36. local CASTING_BAR_COLOR_TEXTURE = "Interface\\AddOns\\eCastingBar\\Textures\\RoundedLightSample.tga";
  37. local CASTING_BAR_BACKGROUND_FILE = "Interface\\Tooltips\\UI-Tooltip-Background";
  38. local CASTING_BAR_EDGE_FILE = "Interface\\Tooltips\\UI-Tooltip-Border";
  39. local CASTING_BAR_EDGE_FILE_UNINT = "Interface\\DialogFrame\\UI-DialogBox-Border";
  40. -- Casting Bar Frame Suffixes
  41. local frameSuffixes = { "", "TargetBar", "FocusBar" }
  42.  
  43. local CASTING_BAR_DEFAULTS = {
  44.   ["Locked"] = 0,
  45.   ["Enabled"] = 1,
  46.   ["Texture"] = "Perl",
  47.   ["ShowTime"] = 1,
  48.   ["HideBorder"] = 0,
  49.   ["ShowDelay"] = 1,
  50.   ["Width"] = CASTING_BAR_WIDTH,
  51.   ["Height"] = CASTING_BAR_HEIGHT,
  52.   ["Left"] = CASTING_BAR_LEFT,
  53.   ["Bottom"] = 180,
  54.   ["ShowSpellName"] = 1,
  55.   ["ShowSpellRank"] = 1,
  56.   ["FontSize"] = 12,
  57.   ["Alpha"] = 100,
  58.   ["IconPosition"] = "HIDDEN",
  59.   ["MirrorLocked"] = 0,
  60.   ["MirrorEnabled"] = 1,
  61.   ["MirrorTexture"] = "Perl",
  62.   ["MirrorShowTime"] = 1,
  63.   ["MirrorHideBorder"] = 0,
  64.   ["MirrorUseFlightTimer"] = 1,
  65.   ["MirrorWidth"] = CASTING_BAR_WIDTH,
  66.   ["MirrorHeight"] = CASTING_BAR_HEIGHT,
  67.   ["MirrorLeft"] = CASTING_BAR_LEFT,
  68.   ["MirrorBottom"] = 600,
  69.   ["MirrorShowTimerLabel"] = 1,
  70.   ["MirrorFontSize"] = 12,
  71.   ["MirrorAlpha"] = 100,
  72.   ["TargetBarLocked"] = 0,
  73.   ["TargetBarEnabled"] = 1,
  74.   ["TargetBarTexture"] = "Perl",
  75.   ["TargetBarShowTime"] = 1,
  76.   ["TargetBarHideBorder"] = 0,
  77.   ["TargetBarShowDelay"] = 1,
  78.   ["TargetBarWidth"] = CASTING_BAR_WIDTH,
  79.   ["TargetBarHeight"] = CASTING_BAR_HEIGHT,
  80.   ["TargetBarLeft"] = CASTING_BAR_LEFT,
  81.   ["TargetBarBottom"] = 640,
  82.   ["TargetBarShowSpellName"] = 1,
  83.   ["TargetBarShowSpellRank"] = 1,
  84.   ["TargetBarFontSize"] = 12,
  85.     ["TargetBarAlpha"] = 100,
  86.   ["TargetBarIconPosition"] = "HIDDEN",
  87.   ["FocusBarLocked"] = 0,
  88.   ["FocusBarEnabled"] = 1,
  89.   ["FocusBarTexture"] = "Perl",
  90.   ["FocusBarShowTime"] = 1,
  91.   ["FocusBarHideBorder"] = 0,
  92.   ["FocusBarShowDelay"] = 1,
  93.   ["FocusBarWidth"] = CASTING_BAR_WIDTH,
  94.   ["FocusBarHeight"] = CASTING_BAR_HEIGHT,
  95.   ["FocusBarLeft"] = CASTING_BAR_LEFT,
  96.   ["FocusBarBottom"] = 560,
  97.   ["FocusBarShowSpellName"] = 1,
  98.   ["FocusBarShowSpellRank"] = 1,
  99.   ["FocusBarFontSize"] = 12,
  100.     ["FocusBarAlpha"] = 100,
  101.   ["FocusBarIconPosition"] = "HIDDEN"
  102. }
  103.  
  104. local CASTING_BAR_DEFAULT_COLORS = {
  105.   ["SpellColor"] = {1.0, 0.7, 0.0, 1.0},
  106.   ["ChannelColor"] = {0.3, 0.3, 1.0, 1},
  107.   ["SuccessColor"] = {0.0, 1.0, 0.0, 1},
  108.   ["FailedColor"] = {1.0, 0.0, 0.0, 1},
  109.   ["FlashBorderColor"] = {1.0, 0.88, 0.25, 1},
  110.   ["FeignDeathColor"] = {1.0, 0.7, 0.0, 1},
  111.   ["ExhaustionColor"] = {1.0, 0.9, 0.0, 1},
  112.   ["BreathColor"] = {0.0, 0.5, 1.0, 1},
  113.   ["FlightColor"] = {.26, 0.93, 1.0, 1.0},
  114.   ["TimeColor"] = {1.0, 1.0, 1.0, 1},
  115.   ["DelayColor"] = {1.0, 0.0, 0.0, 1},
  116.   ["MirrorTimeColor"] = {1.0, 1.0, 1.0, 1},
  117.   ["MirrorFlashBorderColor"] = {1.0, 0.88, 0.25, 1},
  118.   ["TargetBarSpellColor"] = {1.0, 0.7, 0.0, 1.0},
  119.   ["TargetBarChannelColor"] = {0.3, 0.3, 1.0, 1},
  120.   ["TargetBarSuccessColor"] = {0.0, 1.0, 0.0, 1},
  121.   ["TargetBarFailedColor"] = {1.0, 0.0, 0.0, 1},
  122.   ["TargetBarFlashBorderColor"] = {1.0, 0.88, 0.25, 1},
  123.   ["TargetBarTimeColor"] = {1.0, 1.0, 1.0, 1},
  124.   ["TargetBarDelayColor"] = {1.0, 0.0, 0.0, 1},
  125.   ["FocusBarSpellColor"] = {1.0, 0.7, 0.0, 1.0},
  126.   ["FocusBarChannelColor"] = {0.3, 0.3, 1.0, 1},
  127.   ["FocusBarSuccessColor"] = {0.0, 1.0, 0.0, 1},
  128.   ["FocusBarFailedColor"] = {1.0, 0.0, 0.0, 1},
  129.   ["FocusBarFlashBorderColor"] = {1.0, 0.88, 0.25, 1},
  130.   ["FocusBarTimeColor"] = {1.0, 1.0, 1.0, 1},
  131.   ["FocusBarDelayColor"] = {1.0, 0.0, 0.0, 1}
  132. }
  133.  
  134. -- Local variables
  135.  
  136. local eCastingBar__FlashBorders = {
  137.     "TOPLEFT",
  138.     "TOP",
  139.     "TOPRIGHT",
  140.     "LEFT",
  141.     "RIGHT",
  142.     "BOTTOMLEFT",
  143.     "BOTTOM",
  144.     "BOTTOMRIGHT"  
  145. }
  146.  
  147.  
  148. function ECB_addChat(msg)
  149.     DEFAULT_CHAT_FRAME:AddMessage(CASTINGBAR_HEADER.." "..msg)
  150. end
  151.  
  152. function eCastingBar_Toggle()
  153.     if eCB_OptionFrame:IsVisible() then
  154.         HideUIPanel(eCB_OptionFrame);
  155.     else
  156.         ShowUIPanel(eCB_OptionFrame);
  157.     end
  158. end
  159.  
  160. function eCastingBar_OnLoad(self, unit, frame)
  161.     self:RegisterEvent("UNIT_SPELLCAST_START");
  162.     self:RegisterEvent("UNIT_SPELLCAST_STOP");
  163.     self:RegisterEvent("UNIT_SPELLCAST_FAILED");
  164.     self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED");
  165.     self:RegisterEvent("UNIT_SPELLCAST_DELAYED");
  166.     self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START");
  167.     self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE");
  168.     self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP");
  169.     self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE");
  170.     self:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE");
  171.     self:RegisterEvent("PLAYER_ENTERING_WORLD");
  172.  
  173.     self.unit = unit;
  174.     self.frame = frame;
  175.     self.casting = nil;
  176.     self.channeling = nil;
  177.     self.holdTime = 0;
  178. end
  179.  
  180.  
  181.  
  182. --[[ Handles all the mods' events. ]]--
  183.  
  184. function eCastingBar_OnEvent(self, newevent, ...)
  185.     local newarg1 = ...;
  186.  
  187.     local unit = self.unit;
  188.     if newevent == "PLAYER_ENTERING_WORLD" then
  189.         self:Hide();
  190.         local nameChannel  = UnitChannelInfo(unit);
  191.         local nameSpell  = UnitCastingInfo(unit);
  192.         if ( nameChannel ) then
  193.             newevent = "UNIT_SPELLCAST_CHANNEL_START";
  194.             newarg1 = unit;
  195.         elseif ( nameSpell ) then
  196.             newevent = "UNIT_SPELLCAST_START";
  197.             newarg1 = unit;
  198.         end
  199.     end
  200.     if ( newarg1 ~= unit ) then
  201.         return;
  202.     end
  203.     local name = self:GetName();
  204.     local barIcon = _G[name.."StatusBarIcon"];
  205.     local barFlash = _G[name.."Flash"]
  206.     local barStatusBar = _G[name.."StatusBar"];
  207.     local barSpark = _G[name.."StatusBarSpark"];
  208.     local barText = _G[name.."StatusBarText"]
  209.     local frame = self.frame
  210.     if( newevent == "UNIT_SPELLCAST_START" ) then
  211.         local displayName, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(unit)
  212.         local spellName, spellRank = displayName, ""
  213.         if ( not spellName) then
  214.             self:Hide();
  215.             return;
  216.         end
  217.         local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[frame.."SpellColor"])
  218.         barStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  219.         if ( barSpark ) then
  220.             barSpark:Show();
  221.         end
  222.         self.startTime = (startTime/1000)
  223.         self.maxValue = (endTime/1000)
  224.         barStatusBar:SetMinMaxValues( self.startTime, self.maxValue )
  225.         barStatusBar:SetValue( self.startTime )
  226.       -- set the text to the spell name
  227.       if ( eCastingBar_Saved[frame.."ShowSpellName"] == 1 and string.len(spellRank) > 0 and eCastingBar_Saved[frame.."ShowSpellRank"] == 1) then
  228.           barText:SetText( spellName.." ("..spellRank..")" )
  229.         elseif ( eCastingBar_Saved[frame.."ShowSpellName"] == 1 and ( string.len(spellRank) == 0 or eCastingBar_Saved[frame.."ShowSpellRank"] == 0 ) ) then
  230.           barText:SetText( spellName )
  231.         elseif ( eCastingBar_Saved[frame.."ShowSpellName"] == 0 and eCastingBar_Saved[frame.."ShowSpellRank"] == 1) then
  232.           barText:SetText( spellRank )
  233.       else
  234.         barText:SetText( "" )
  235.       end
  236.         if ( barIcon and eCastingBar_Saved[frame.."IconPosition"] ~= "HIDDEN") then
  237.             barIcon:SetTexture(texture);
  238.             barIcon:Show();
  239.         end
  240.         self:SetAlpha( 1.0 )
  241.         self.holdTime = 0
  242.         self.casting = 1
  243.         self.castID = castID;
  244.         self.channeling = nil
  245.         self.fadeOut = nil
  246.         self.delay = 0
  247.         if eCastingBar_Saved[frame.."HideBorder"] == 0 then
  248.             if (notInterruptible) then
  249.                         self:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE_UNINT, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  250.                         self:SetBackdropColor(0,0,0,0.5)
  251.             else
  252.                 self:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  253.                         self:SetBackdropColor(0,0,0,0.5)
  254.             end
  255.         end
  256.         if (eCastingBar_Saved[frame.."Enabled"] == 1) then
  257.             self:Show()
  258.         end
  259.  
  260.     elseif( newevent == "UNIT_SPELLCAST_STOP" ) or ( newevent == "UNIT_SPELLCAST_CHANNEL_STOP" ) then
  261.         if ( not self:IsVisible() ) then
  262.             self:Hide()
  263.         end
  264.         if ( (self.casting and newevent == "UNIT_SPELLCAST_STOP" and select(4, ...) == self.castID) or
  265.              (self.channeling and newevent == "UNIT_SPELLCAST_CHANNEL_STOP") ) then
  266.             barSpark:Hide();
  267.             barFlash:SetAlpha(0.0);
  268.             barFlash:Show();
  269.             barStatusBar:SetValue(self.maxValue);
  270.             if ( newevent == "UNIT_SPELLCAST_STOP" ) then
  271.                 local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[frame.."SuccessColor"])
  272.                 barStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  273.                 self.casting = nil;
  274.             else
  275.                 self.channeling = nil;
  276.             end
  277.             self.delay = 0
  278.             self.flash = 1;
  279.             self.fadeOut = 1;
  280.             self.holdTime = 0
  281.         end
  282.  
  283.     elseif( newevent == "UNIT_SPELLCAST_FAILED" or newevent == "UNIT_SPELLCAST_INTERRUPTED" ) then
  284.         if ( self:IsShown() and
  285.              (self.casting and select(4, ...) == self.castID) and not self.fadeOut ) then
  286.             barStatusBar:SetValue( self.maxValue )
  287.         local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[frame.."FailedColor"])
  288.         barStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  289.             barSpark:Hide()
  290.             if ( newevent == "UNIT_SPELLCAST_FAILED" ) then
  291.                 barText:SetText( FAILED )
  292.             else
  293.                 barText:SetText( INTERRUPTED )
  294.             end
  295.             self.casting = nil
  296.             self.channeling = nil
  297.             self.delay = 0
  298.             self.fadeOut = 1
  299.             self.holdTime = GetTime() + CASTING_BAR_HOLD_TIME
  300.         end
  301.    
  302.     elseif( newevent == "UNIT_SPELLCAST_DELAYED" ) then
  303.         if( self:IsShown() ) then
  304.             local displayName, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(unit)
  305.             local spellName, spellRank = displayName, ""
  306.             if (not endTime) then return; end;
  307.             local delayTime = (endTime - (self.maxValue * 1000))
  308.             if ( not spellName) then
  309.                 self:Hide();
  310.                 return;
  311.             end
  312.             self.startTime = (startTime/1000)
  313.             self.maxValue = (endTime/1000)
  314.             barStatusBar:SetMinMaxValues( self.startTime, self.maxValue )
  315.         if self.delay == nil then
  316.         self.delay = 0
  317.         end
  318.             self.delay = self.delay + (delayTime / 1000)
  319.             if ( not self.casting ) then
  320.                 local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[frame.."SpellColor"])
  321.                 barStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  322.                 barSpark:Show();
  323.                 barFlash:SetAlpha(0.0);
  324.                 barFlash:Hide();
  325.                 self.casting = 1;
  326.                 self.channeling = nil;
  327.                 self.flash = 0;
  328.                 self.fadeOut = 0;
  329.             end
  330.         end
  331.        
  332.     elseif( newevent == "UNIT_SPELLCAST_CHANNEL_START" ) then
  333.         local displayName, texture, startTime, endTime, isTradeSkill, notInterruptible = UnitChannelInfo(newarg1)
  334.         local spellName, spellRank = displayName, ""
  335.         if ( not spellName) then
  336.             self:Hide();
  337.             return;
  338.         end
  339.     local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[frame.."ChannelColor"])
  340.     barStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  341.         self.startTime = (startTime/1000)
  342.         self.endTime = (endTime/1000)
  343.         self.maxValue = self.startTime
  344.         barStatusBar:SetMinMaxValues( self.startTime, self.endTime )
  345.         barStatusBar:SetValue( endTime - ( GetTime() - (startTime/1000) ) )
  346.         barSpark:Show()
  347.         if ( barIcon and eCastingBar_Saved[frame.."IconPosition"] ~= "HIDDEN") then
  348.             barIcon:SetTexture(texture);
  349.             barIcon:Show();
  350.         end
  351.       if ( eCastingBar_Saved[frame.."ShowSpellName"] == 1 and string.len(spellRank) > 0 and eCastingBar_Saved[frame.."ShowSpellRank"] == 1) then
  352.           barText:SetText( spellName.." ("..spellRank..")" )
  353.       elseif ( eCastingBar_Saved[frame.."ShowSpellName"] == 1 and ( string.len(spellRank) == 0 or eCastingBar_Saved[frame.."ShowSpellRank"] == 0 ) ) then
  354.           barText:SetText( spellName )
  355.         elseif ( eCastingBar_Saved[frame.."ShowSpellName"] == 0 and eCastingBar_Saved[frame.."ShowSpellRank"] == 1) then
  356.           barText:SetText( spellRank )
  357.         else
  358.             barText:SetText( "" )
  359.         end
  360.         self:SetAlpha( 1.0 )
  361.     self.delay = 0
  362.         self.holdTime = 0
  363.         self.casting = nil
  364.         self.channeling = 1
  365.         self.fadeOut = nil
  366.         if (notInterruptible) then
  367.                     self:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE_UNINT, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  368.                     self:SetBackdropColor(0,0,0,0.5)
  369.         else
  370.             self:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  371.                     self:SetBackdropColor(0,0,0,0.5)
  372.         end
  373.         if (  eCastingBar_Saved[frame.."Enabled"] == 1) then
  374.             self:Show()
  375.         end
  376.  
  377.     elseif( newevent == "UNIT_SPELLCAST_CHANNEL_UPDATE" ) then
  378.         if( self:IsShown() ) then
  379.             local displayName, texture, startTime, endTime = UnitChannelInfo(newarg1)
  380.             local spellName, spellRank = displayName, ""
  381.             if ( not spellName) then
  382.                 self:Hide();
  383.                 return;
  384.             end
  385.             self.startTime = startTime / 1000;
  386.             self.endTime = endTime / 1000;
  387.             self.maxValue = self.startTime;
  388.             barStatusBar:SetMinMaxValues(self.startTime, self.endTime);        
  389.         end
  390.     elseif ( newevent == "UNIT_SPELLCAST_INTERRUPTIBLE" ) then
  391.         if eCastingBar_Saved[frame.."HideBorder"] == 0 then
  392.             self:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE_UNINT, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  393.             self:SetBackdropColor(0,0,0,0.5)
  394.         end
  395.     elseif ( newevent == "UNIT_SPELLCAST_NOT_INTERRUPTIBLE" ) then
  396.         if eCastingBar_Saved[frame.."HideBorder"] == 0 then
  397.             self:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE_UNINT, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  398.             self:SetBackdropColor(0,0,0,0.5)
  399.         end
  400.     end
  401. end
  402.  
  403. function eCastingBar_OnUpdate(self, elapsed)
  404.     local frame = self.frame
  405.     local bar = _G["eCastingBar"..frame]
  406.     local barFlash = _G["eCastingBar"..frame.."Flash"]
  407.     local barStatusBar = _G["eCastingBar"..frame.."StatusBar"];
  408.     local barSpark = _G["eCastingBar"..frame.."StatusBarSpark"];
  409.     local barTime = _G["eCastingBar"..frame.."StatusBar_Time"];
  410.     local barDelay = _G["eCastingBar"..frame.."StatusBar_Delay"];
  411.     local barTexture = _G["eCastingBar"..frame.."StatusBarTexture"];
  412.   if( self.casting ) then    
  413.     local intCurrentTime = GetTime()
  414.     if (intCurrentTime > self.maxValue) then
  415.         intCurrentTime = self.maxValue
  416.     end
  417.         if ( intCurrentTime == self.maxValue ) then
  418.             barStatusBar:SetValue(self.maxValue);
  419.             barTexture:SetTexCoord(0,1,0,1);
  420.           local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[frame.."SuccessColor"])
  421.             barStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  422.             self.flash = 1;
  423.             self.delay = 0;
  424.             self.fadeOut = 1;
  425.             self.casting = nil;
  426.             self.channeling = nil;
  427.             return;
  428.         end
  429.     barTexture:SetTexCoord(0,( intCurrentTime - self.startTime ) / ( self.maxValue - self.startTime ), 0, 1)
  430.     barStatusBar:SetValue( intCurrentTime )
  431.     barFlash:Hide()
  432.     local sparkPosition = ( ( intCurrentTime - self.startTime ) / ( self.maxValue - self.startTime ) ) * barStatusBar:GetWidth()
  433.     if( sparkPosition < 0 ) then
  434.        
  435.       sparkPosition = 0
  436.     end
  437.     barSpark:SetPoint( "CENTER", "eCastingBar"..frame.."StatusBar", "LEFT", sparkPosition, 0 )
  438.     if ( eCastingBar_Saved[frame.."ShowTime"] == 1) then
  439.       barTime:SetText( string.format( "%.1f", math.max( self.maxValue - intCurrentTime, 0.0 ) ) )
  440.     else
  441.       barTime:SetText("")
  442.     end
  443.     if (( eCastingBar_Saved[frame.."ShowDelay"] == 1 ) and ( self.delay ~= 0)) then  
  444.         barDelay:SetText("+"..string.format( "%.1f", self.delay ) )
  445.     else
  446.       barDelay:SetText("")
  447.     end
  448.   -- no, we channeling?
  449.   elseif ( self.channeling ) then
  450.     -- yes
  451.     local intTimeLeft = GetTime()
  452.         if ( intTimeLeft > self.endTime ) then
  453.             intTimeLeft = self.endTime;
  454.         end
  455.         if ( intTimeLeft == self.endTime ) then
  456.           local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[frame.."SuccessColor"])
  457.             barStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  458.             self.flash = 1;
  459.             self.delay = 0;
  460.             self.fadeOut = 1;
  461.             self.casting = nil;
  462.             self.channeling = nil;
  463.             return;
  464.         end
  465.     local intBarValue = self.startTime + ( self.endTime - intTimeLeft )
  466.     barTexture:SetTexCoord(0,( intBarValue - self.startTime ) / ( self.endTime - self.startTime ), 0, 1)
  467.     barStatusBar:SetValue( intBarValue )
  468.     barFlash:Hide()
  469.     local sparkPosition = ( ( intBarValue - self.startTime ) / ( self.endTime - self.startTime ) ) * _G["eCastingBar"..frame.."Background"]:GetWidth()
  470.     barSpark:SetPoint( "CENTER", "eCastingBar"..frame.."StatusBar", "LEFT", sparkPosition, 0 )
  471.     if (eCastingBar_Saved[frame.."ShowTime"] == 1) then    
  472.       local timeLeft = math.max( _G["eCastingBar"..frame].endTime - intTimeLeft, 0.0 )
  473.       local timeMsg = nil
  474.       local minutes = 0
  475.       local seconds = 0
  476.      
  477.       if (timeLeft > 60) then
  478.         minutes = math.floor( ( timeLeft / 60 ))
  479.         local seconds = math.ceil( timeLeft - ( 60 * minutes ))
  480.         if (seconds == 60) then
  481.           minutes = minutes + 1
  482.           seconds = 0
  483.         end
  484.         timeMsg = format("%s:%s", minutes, getFormattedNumber(seconds))
  485.       else
  486.         timeMsg = string.format( "%.1f", timeLeft )
  487.       end
  488.       barTime:SetText( timeMsg )
  489.     else
  490.       barTime:SetText("")
  491.     end
  492.     if ((eCastingBar_Saved[frame.."ShowDelay"] == 1) and (self.delay ~= 0)) then
  493.       barDelay:SetText("+"..string.format( "%.1f", self.delay ) )
  494.     else
  495.       barDelay:SetText("")
  496.     end
  497.   elseif( GetTime() < self.holdTime ) then
  498.     return
  499.   elseif( self.flash ) then
  500.     local intAlpha = barFlash:GetAlpha() + CASTING_BAR_FLASH_STEP
  501.     barTime:SetText( "" )
  502.     if( intAlpha < 1 ) then
  503.       barFlash:SetAlpha( intAlpha )
  504.     else
  505.             barFlash:SetAlpha(1.0);
  506.       self.flash = nil
  507.     end
  508.   elseif ( self.fadeOut ) then
  509.     local intAlpha = self:GetAlpha() - CASTING_BAR_ALPHA_STEP
  510.     if( intAlpha > 0 ) then
  511.       self:SetAlpha( intAlpha )
  512.     else
  513.       self.fadeOut = nil
  514.       self:Hide()
  515.     end
  516.   end
  517. end
  518.  
  519. function eCastingBarTarget_OnEvent(self, event, ...)
  520.     local newevent = event;
  521.     local newarg1 = ...;
  522.     if( newevent == "PLAYER_TARGET_CHANGED") then
  523.         local nameChannel  = UnitChannelInfo(self.unit);
  524.         local nameSpell  = UnitCastingInfo(self.unit);
  525.         if ( nameChannel ) then
  526.             newevent = "UNIT_SPELLCAST_CHANNEL_START";
  527.             newarg1 = "target";
  528.         elseif ( nameSpell ) then
  529.             newevent = "UNIT_SPELLCAST_START";
  530.             newarg1 = "target";
  531.         else
  532.             self.casting = nil;
  533.             self.channeling = nil;
  534.             self:Hide();
  535.             return;
  536.         end
  537.     end
  538.     if UnitIsUnit("player", "target") then
  539.         return;
  540.     end
  541.     eCastingBar_OnEvent(self, newevent, newarg1, select(2, ...));
  542.  
  543. end
  544.  
  545. function eCastingBarFocus_OnEvent(self, event, ...)
  546.     local newevent = event;
  547.     local newarg1 = ...;
  548.     if( event == "PLAYER_FOCUS_CHANGED") then
  549.         local nameChannel  = UnitChannelInfo(self.unit);
  550.         local nameSpell  = UnitCastingInfo(self.unit);
  551.         if ( nameChannel ) then
  552.             newevent = "UNIT_SPELLCAST_CHANNEL_START";
  553.             newarg1 = "focus";
  554.         elseif ( nameSpell ) then
  555.             newevent = "UNIT_SPELLCAST_START";
  556.             newarg1 = "focus";
  557.         else
  558.             self.casting = nil;
  559.             self.channeling = nil;
  560.             self:Hide();
  561.             return;
  562.         end
  563.     end
  564.     if ( UnitIsUnit("player", "focus") ) then
  565.         return;
  566.     end
  567.     eCastingBar_OnEvent(self, newevent, newarg1,  select(2, ...));
  568.  
  569. end
  570.  
  571.  
  572. function eCastingBar_ResetSettings()
  573.     ECB_addChat(CASTINGBAR_RESET)
  574.     eCastingBar_Saved = {}
  575.   -- reset General Options
  576.     for option in pairs(CASTING_BAR_DEFAULTS) do
  577.         eCastingBar_Saved[option] = CASTING_BAR_DEFAULTS[option]
  578.     end
  579.   -- reset Colors
  580.     for color in pairs(CASTING_BAR_DEFAULT_COLORS) do
  581.         eCastingBar_Saved[color] = CASTING_BAR_DEFAULT_COLORS[color]
  582.     end
  583.     setup()
  584. end
  585.  
  586. function eCastingBar_CheckSettings()
  587.   -- reset General Options
  588.     for option in pairs(CASTING_BAR_DEFAULTS) do
  589.         if (eCastingBar_Saved[option] == nil) then
  590.             eCastingBar_Saved[option] = CASTING_BAR_DEFAULTS[option]
  591.         end
  592.     end
  593.   -- check for nil colors
  594.     for color in pairs(CASTING_BAR_DEFAULT_COLORS) do
  595.         if (eCastingBar_Saved[color] == nil) then
  596.             eCastingBar_Saved[color] = CASTING_BAR_DEFAULT_COLORS[color]
  597.         end
  598.     end
  599. end
  600.  
  601. function setup()
  602.     eCastingBar_checkEnabled()
  603.     eCastingBar_checkLocked()
  604.     eCastingBar_checkBorders()
  605.     eCastingBar_checkTimeColors()
  606.     eCastingBar_setDelayColor()
  607.     eCastingBar_SetSize()
  608.     eCastingBar_checkFlashBorderColors()
  609.     eCastingBar_checkTextures()
  610.     eCastingBar_setIcons()
  611. end
  612.  
  613. --[[ Iniitialization ]]--
  614.  
  615. function eCastingBar_LoadVariables()   
  616.     setup()
  617.     eCastingBar_SetSavedSettingsMenu()
  618.    
  619.     -- make the casting bar link to the movable button
  620.         eCastingBar:SetPoint("TOPLEFT", "eCastingBar_Outline", "TOPLEFT", 0, 0 )
  621.         eCastingBarTargetBar:SetPoint("TOPLEFT", "eCastingBarTargetBar_Outline", "TOPLEFT", 0, 0 )
  622.         eCastingBarFocusBar:SetPoint("TOPLEFT", "eCastingBarFocusBar_Outline", "TOPLEFT", 0, 0 )
  623.    
  624.     -- make the mirror casting bar link to the movable button
  625.         eCastingBarMirror1:SetPoint("TOPLEFT", "eCastingBarMirror_Outline", "TOPLEFT", 0, 0 )
  626.        
  627.     -- reset variables
  628.     for index, option in pairs(frameSuffixes) do
  629.       _G["eCastingBar"..option].casting = nil
  630.       _G["eCastingBar"..option].holdTime = 0
  631.     end
  632.    
  633.         SlashCmdList["ECASTINGBAR"] = eCastingBar_SlashHandler
  634.         SLASH_ECASTINGBAR1 = "/eCastingBar"
  635.         SLASH_ECASTINGBAR2 = "/eCB"
  636.         SLASH_ECASTINGBAR3 = "/???"    
  637.     -- resolution
  638.     SetResolution(GetScreenResolutions())
  639.     --[[
  640.     local i,j = string.find(eCastingBar_Resolution, "x")
  641.     eCastingBar_ResolutionWidth = tonumber(string.sub(eCastingBar_Resolution, 0, i - 1))
  642.     eCastingBar_ResolutionHeight = tonumber(string.sub(eCastingBar_Resolution, i + 1, string.len(eCastingBar_Resolution)))
  643.     ]]
  644.     -- override these for now until I can figure out why blizzard is jacked up
  645.     eCastingBar_ResolutionWidth = 2000
  646.     eCastingBar_ResolutionHeight = 2000
  647.    
  648.     setupConfigFrame()
  649.     setupDefaultConfigFrame()
  650.     setupColorsConfigFrame()
  651. end
  652.  
  653. function setupConfigFrame()
  654.   -- set all text values
  655.   eCB_Option_DefaultsButton:SetText(CASTINGBAR_DEFAULTS_BUTTON)
  656.   eCB_Option_CloseButton:SetText(CASTINGBAR_CLOSE_BUTTON)
  657.   eCastingBarSaveSettingsButton:SetText(CASTINGBAR_SAVE_BUTTON)
  658.   eCastingBarLoadSettingsButton:SetText(CASTINGBAR_LOAD_BUTTON)
  659.   eCastingBarDeleteSettingsButton:SetText(CASTINGBAR_DELETE_BUTTON)
  660. end
  661.  
  662. function setupDefaultConfigFrame()
  663.   -- set all text values
  664.   for option in pairs(CASTING_BAR_BUTTONS) do
  665.     local btnText = _G["eCastingBar"..option.."Text"]
  666.     btnText:SetText(CASTING_BAR_BUTTONS[option])
  667.   end
  668.  
  669.   eCastingBarStatusBarText:SetJustifyH(CASTING_BAR_SPELL_JUSTIFY)
  670.   eCastingBarSelectTexture_Label:SetText(CASTINGBAR_CASTINGBAR_TEXTURE_TEXT)
  671.   eCastingBarSelectTexture_Setting:SetText(eCastingBar_Saved.Texture)
  672.  
  673.   eCastingBarIconPosition_Label:SetText(CASTINGBAR_ICON_POSITION_TEXT)
  674.   eCastingBarIconPosition_Setting:SetText(_G["CASTINGBAR_"..eCastingBar_Saved.IconPosition.."_TEXT"])
  675.  
  676.     for index, option in pairs(frameSuffixes) do
  677.         local   Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[option.."SpellColor"])
  678.         _G["eCastingBar"..option.."ExampleStatusBar"]:SetStatusBarColor( Red, Green, Blue, Alpha )
  679.     end
  680.   local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved.BreathColor)
  681.   eCastingBarMirrorExampleStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  682.  
  683.  
  684.   eCastingBarTargetBarStatusBarText:SetJustifyH(CASTING_BAR_SPELL_JUSTIFY)
  685.   eCastingBarTargetBarSelectTexture_Label:SetText(CASTINGBAR_TARGETBAR_TEXTURE_TEXT)
  686.   eCastingBarTargetBarSelectTexture_Setting:SetText(eCastingBar_Saved.TargetBarTexture)
  687.  
  688.   eCastingBarFocusBarStatusBarText:SetJustifyH(CASTING_BAR_SPELL_JUSTIFY)
  689.   eCastingBarFocusBarSelectTexture_Label:SetText(CASTINGBAR_FOCUSBAR_TEXTURE_TEXT)
  690.   eCastingBarFocusBarSelectTexture_Setting:SetText(eCastingBar_Saved.FocusBarTexture)
  691.  
  692.   eCastingBarTargetBarIconPosition_Label:SetText(CASTINGBAR_ICON_POSITION_TEXT)
  693.   eCastingBarTargetBarIconPosition_Setting:SetText(_G["CASTINGBAR_"..eCastingBar_Saved.TargetBarIconPosition.."_TEXT"])
  694.  
  695.   eCastingBarFocusBarIconPosition_Label:SetText(CASTINGBAR_ICON_POSITION_TEXT)
  696.   eCastingBarFocusBarIconPosition_Setting:SetText(_G["CASTINGBAR_"..eCastingBar_Saved.FocusBarIconPosition.."_TEXT"])
  697.  
  698.   eCastingBarMirrorSelectTexture_Label:SetText(CASTINGBAR_MIRRORBAR_TEXTURE_TEXT)
  699.   eCastingBarMirrorSelectTexture_Setting:SetText(eCastingBar_Saved.MirrorTexture)
  700.  
  701.   for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  702.     _G["eCastingBarMirror"..index.."StatusBarText"]:SetJustifyH(CASTING_BAR_SPELL_JUSTIFY)
  703.   end
  704.  
  705.     -- Disable the Load and Delete Buttons on Startup
  706.     eCastingBarLoadSettingsButton:Disable();
  707.     eCastingBarDeleteSettingsButton:Disable();
  708.  
  709.   -- set all checks
  710.   for option in pairs(CASTING_BAR_BUTTONS) do
  711.     local btn = _G["eCastingBar"..option]
  712.     btn:SetChecked(eCastingBar_Saved[option])
  713.   end
  714.  
  715.   local slider, sliderText, low, high, width, height
  716.   local optionTabs = { "", "Mirror", "TargetBar", "FocusBar" }
  717.  
  718.   for index, option in pairs(optionTabs) do
  719.     local slidervalue
  720.     -- setup the width slider
  721.     slider = _G["eCastingBar"..option.."WidthSlider"]
  722.     sliderText = _G["eCastingBar"..option.."WidthSliderText"]
  723.     low = _G["eCastingBar"..option.."WidthSliderLow"]
  724.     high = _G["eCastingBar"..option.."WidthSliderHigh"]
  725.     slidervalue = eCastingBar_Saved[option.."Width"]
  726.     slider:SetMinMaxValues(CASTING_BAR_SLIDER_WIDTH_MIN, eCastingBar_ResolutionWidth)
  727.     slider:SetValueStep(1)
  728.     slider:SetValue(slidervalue)
  729.     sliderText:SetText(CASTINGBAR_SLIDER_WIDTH_TEXT)
  730.     low:SetText(CASTING_BAR_SLIDER_WIDTH_MIN)
  731.     high:SetText(eCastingBar_ResolutionWidth)
  732.    
  733.     -- setup the height slider
  734.     slidervalue = eCastingBar_Saved[option.."Height"]
  735.     slider = _G["eCastingBar"..option.."HeightSlider"]
  736.     sliderText = _G["eCastingBar"..option.."HeightSliderText"]
  737.     low = _G["eCastingBar"..option.."HeightSliderLow"]
  738.     high = _G["eCastingBar"..option.."HeightSliderHigh"]
  739.    
  740.     slider:SetMinMaxValues(CASTING_BAR_SLIDER_HEIGHT_MIN, CASTING_BAR_SLIDER_HEIGHT_MAX)
  741.     slider:SetValueStep(1)
  742.     slider:SetValue(slidervalue)
  743.     sliderText:SetText(CASTINGBAR_SLIDER_HEIGHT_TEXT)
  744.     low:SetText(CASTING_BAR_SLIDER_HEIGHT_MIN)
  745.     high:SetText(CASTING_BAR_SLIDER_HEIGHT_MAX)
  746.    
  747.     -- setup the x slider
  748.     slider = _G["eCastingBar"..option.."LeftSlider"]
  749.     sliderText = _G["eCastingBar"..option.."LeftSliderText"]
  750.     low = _G["eCastingBar"..option.."LeftSliderLow"]
  751.     high = _G["eCastingBar"..option.."LeftSliderHigh"]
  752.    
  753.     if (option == "Mirror") then
  754.       width = tonumber(string.format("%.0f", _G["eCastingBarMirror1"]:GetWidth()))
  755.       height = tonumber(string.format("%.0f", _G["eCastingBarMirror1"]:GetHeight()))
  756.     else
  757.       width = tonumber(string.format("%.0f", _G["eCastingBar"..option]:GetWidth()))
  758.       height = tonumber(string.format("%.0f", _G["eCastingBar"..option]:GetHeight()))
  759.     end
  760.     slidervalue = eCastingBar_Saved[option.."Left"]
  761.     slider:SetMinMaxValues(-1000, eCastingBar_ResolutionWidth)
  762.     slider:SetValueStep(1)
  763.     slider:SetValue(slidervalue)
  764.     sliderText:SetText(CASTINGBAR_SLIDER_LEFT_TEXT)
  765.     low:SetText(-1000)
  766.     high:SetText(eCastingBar_ResolutionWidth)
  767.    
  768.     -- setup the y slider
  769.     slider = _G["eCastingBar"..option.."BottomSlider"]
  770.     sliderText = _G["eCastingBar"..option.."BottomSliderText"]
  771.     low = _G["eCastingBar"..option.."BottomSliderLow"]
  772.     high = _G["eCastingBar"..option.."BottomSliderHigh"]
  773.    
  774.     slidervalue = eCastingBar_Saved[option.."Bottom"]
  775.     slider:SetMinMaxValues(-1000, eCastingBar_ResolutionHeight)
  776.     slider:SetValueStep(1)
  777.     slider:SetValue(slidervalue)
  778.     sliderText:SetText(CASTINGBAR_SLIDER_BOTTOM_TEXT)
  779.     low:SetText(-1000)
  780.     high:SetText(eCastingBar_ResolutionHeight)
  781.    
  782.     -- setup the font slider
  783.     slider = _G["eCastingBar"..option.."FontSlider"]
  784.     sliderText = _G["eCastingBar"..option.."FontSliderText"]
  785.     low = _G["eCastingBar"..option.."FontSliderLow"]
  786.     high = _G["eCastingBar"..option.."FontSliderHigh"]
  787.    
  788.     slidervalue = eCastingBar_Saved[option.."FontSize"]
  789.     slider:SetMinMaxValues(6, 40)
  790.     slider:SetValueStep(1)
  791.     slider:SetValue(slidervalue)
  792.     sliderText:SetText(CASTINGBAR_SLIDER_FONT_TEXT)
  793.     low:SetText(6)
  794.     high:SetText(40)
  795.    
  796.     -- setup the alpha slider
  797.     slider = _G["eCastingBar"..option.."AlphaSlider"]
  798.     sliderText = _G["eCastingBar"..option.."AlphaSliderText"]
  799.  
  800.     low = _G["eCastingBar"..option.."AlphaSliderLow"]
  801.     high = _G["eCastingBar"..option.."AlphaSliderHigh"]
  802.     slidervalue = eCastingBar_Saved[option.."Alpha"]
  803.     slider:SetMinMaxValues(0, 100)
  804.     slider:SetValueStep(1)
  805.     slider:SetValue(slidervalue)
  806.     sliderText:SetText(CASTINGBAR_SLIDER_ALPHA_TEXT)
  807.     low:SetText("0%")
  808.     high:SetText("100%")
  809.   end
  810. end
  811.  
  812. function setupColorsConfigFrame()
  813.   -- set the textures
  814.   for color in pairs(CASTINGBAR_COLOR_LABEL) do
  815.     local btnColor = _G["btn"..color.."Texture"]
  816.    
  817.     -- set the texture
  818.     btnColor:SetTexture(CASTING_BAR_COLOR_TEXTURE)
  819.    
  820.     -- set the vertex color
  821.     btnColor:SetVertexColor(unpack(eCastingBar_Saved[color]))
  822.    
  823.     -- set the label
  824.     _G["lbl"..color.."Text"]:SetText(CASTINGBAR_COLOR_LABEL[color])
  825.   end
  826. end
  827.  
  828. function SetResolution(...)
  829.   local iRes = GetCurrentResolution()
  830.   for i=1, select("#",...), 1 do
  831.     if (iRes == i) then
  832.         eCastingBar_Resolution = select(i,...)
  833.     end
  834.   end
  835. end
  836.  
  837. --[[ Handles all the slash commands if cosmos isn't present. ]]--
  838.  
  839. function eCastingBar_SlashHandler( strMessage )
  840.   local command, param
  841.   -- make it it all lower case to be sure
  842.     strMessage = string.lower( strMessage )
  843.  
  844.   if(index) then
  845.         command = string.sub(strMessage, 1, (index - 1))
  846.         param = string.sub(strMessage, (index + 1)  )
  847.     else
  848.         command = strMessage
  849.     end
  850.  
  851.     if( command == CASTINGBAR_CHAT_C1 ) then
  852.     ShowUIPanel(eCB_OptionFrame);
  853.   elseif ( command == CASTINGBAR_CHAT_C2) then
  854.     eCastingBar_ChatHelp()
  855.     else
  856.     ShowUIPanel(eCB_OptionFrame);
  857.     end
  858.    
  859.   setupDefaultConfigFrame()
  860.   setupColorsConfigFrame()
  861. end
  862.  
  863. --[[ Handles chat help messages. ]]--
  864.  
  865. function eCastingBar_ChatHelp()
  866.     local intIndex = 0
  867.     local strMessage = ""
  868.    
  869.   -- prints each line in CASTINGBAR_HELP = { }
  870.     for intIndex, strMessage in pairs(CASTINGBAR_HELP) do
  871.         ECB_addChat( strMessage )
  872.     end
  873. end
  874.  
  875. function getFormattedNumber(number)
  876.     if (strlen(number) < 2 ) then
  877.         return "0"..number
  878.     else
  879.         return number
  880.     end
  881. end
  882.  
  883. --[[ Starts moving the frame. ]]--
  884.  
  885. function eCastingBar_MouseUp( strButton, frmFrame, frameType )
  886.     if( eCastingBar_Saved[frameType.."Locked"] == 0 ) then
  887.         _G[ frmFrame ]:StopMovingOrSizing()
  888.     eCastingBar_Saved[frameType.."Left"] = _G[frmFrame]:GetLeft()
  889.     eCastingBar_Saved[frameType.."Bottom"] = _G[frmFrame]:GetBottom()
  890.    
  891.     _G["eCastingBar"..frameType.."LeftSlider"]:SetValue(eCastingBar_Saved[frameType.."Left"])
  892.     _G["eCastingBar"..frameType.."BottomSlider"]:SetValue(eCastingBar_Saved[frameType.."Bottom"])
  893.     end
  894. end
  895.  
  896. --[[ Stops moving the frame. ]]--
  897.  
  898. function eCastingBar_MouseDown( strButton, frmFrame, frameType )
  899.  
  900.     if( strButton == "LeftButton" and (eCastingBar_Saved[frameType.."Locked"] == 0 ) ) then
  901.         _G[ frmFrame ]:StartMoving()
  902.     end
  903. end
  904.  
  905. function eCastingBarGeneral_MouseUp( strButton, frmFrame )
  906.         _G[ frmFrame ]:StopMovingOrSizing()
  907. end
  908.  
  909. --[[ Stops moving the frame. ]]--
  910.  
  911. function eCastingBarGeneral_MouseDown( strButton, frmFrame, frameType )
  912.     if( strButton == "LeftButton") then
  913.         _G[ frmFrame ]:StartMoving()
  914.     end
  915. end
  916.  
  917. function eCastingBar_getShowDelay()
  918.     return eCastingBar_Saved.ShowDelay
  919. end
  920.  
  921. function eCastingBar_setShowDelay( intShowDelay )
  922.     eCastingBar_Saved.ShowDelay = intShowDelay
  923. end
  924.  
  925. function eCastingBar_checkBorders()
  926.   for index, option in pairs(frameSuffixes) do
  927.     local bar = _G["eCastingBar"..option]
  928.     if (eCastingBar_Saved[option.."HideBorder"] == 1) then
  929.       bar:SetBackdrop(nil)
  930.     else
  931.       bar:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  932.       bar:SetBackdropColor(0,0,0,0.5)
  933.     end
  934.   end
  935.   for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  936.     local bar = _G["eCastingBarMirror"..index]
  937.     if (eCastingBar_Saved.MirrorHideBorder == 1) then
  938.       bar:SetBackdrop(nil)
  939.     else
  940.       bar:SetBackdrop({bgFile = CASTING_BAR_BACKGROUND_FILE, edgeFile = CASTING_BAR_EDGE_FILE, tile = true, tileSize = 16, edgeSize = 16, insets = { left = 2, right = 2, top = 2, bottom = 2 }})
  941.       bar:SetBackdropColor(0,0,0,0.5)
  942.     end
  943.   end
  944. end
  945.  
  946. --[[-------------------------------------------
  947.     Functions for Locked State
  948. -------------------------------------------]]--
  949.  
  950. function eCastingBar_checkLocked()
  951.   for index, option in pairs(frameSuffixes) do
  952.     local barOutline = _G["eCastingBar"..option.."_Outline"]
  953.     -- only show the outline if we are enabled
  954.     if (eCastingBar_Saved[option.."Enabled"] == 1 and
  955.           eCastingBar_Saved[option.."Locked"] == 0) then
  956.       barOutline:Show()
  957.     else
  958.       barOutline:Hide()
  959.     end
  960.   end
  961.  
  962.  
  963.   -- only show the outline if we are enabled
  964.   if (eCastingBar_Saved.MirrorEnabled == 1 and eCastingBar_Saved.MirrorLocked == 0) then
  965.     eCastingBarMirror_Outline:Show()
  966.   else
  967.     eCastingBarMirror_Outline:Hide()
  968.   end
  969. end
  970.  
  971. --[[-------------------------------------------
  972.     Functions for Enabled State
  973. -------------------------------------------]]--
  974.  
  975. --[[ Disables the frame. ]]--
  976.  
  977. function eCastingBar_Disable( frame )
  978.   eCastingBar_Saved[frame.."Enabled"] = 0
  979.   local bar = _G["eCastingBar"..frame]
  980.   if (frame == "") then
  981.         local oldbar = CastingBarFrame
  982.         if (BCastBarCastBar) then
  983.             oldbar = BCastBarCastBar
  984.         end
  985.     oldbar.showCastbar = true
  986.         if UnitCastingInfo(oldbar.unit) or UnitChannelInfo(oldbar.unit) then
  987.         oldbar:Show()
  988.     end
  989.  
  990.   end
  991.     if bar.casting then
  992.         bar:Hide()
  993.     end
  994.   -- the frame unlocked?
  995.     if( eCastingBar_Saved[frame.."Locked"] == 0 ) then
  996.     -- yes, lets hide the outline
  997.         _G["eCastingBar"..frame.."_Outline"]:Hide()
  998.     end
  999. end
  1000.  
  1001.  
  1002. --[[ Enables the frame. ]]--
  1003.  
  1004. function eCastingBar_Enable( frame )
  1005.   eCastingBar_Saved[frame.."Enabled"] = 1  
  1006.   local bar = _G["eCastingBar"..frame]
  1007.   if (frame == "") then
  1008.         local oldbar = CastingBarFrame
  1009.         if (BCastBarCastBar) then
  1010.             oldbar = BCastBarCastBar
  1011.         end
  1012.     oldbar.showCastbar = nil;
  1013.     oldbar:Hide();
  1014.     end
  1015.     if UnitCastingInfo(bar.unit) or UnitChannelInfo(bar.unit) then
  1016.         bar:Show()
  1017.     end
  1018.   -- the frame unlocked?
  1019.     if( eCastingBar_Saved[frame.."Locked"] == 0 ) then
  1020.     -- yes, lets show the outline
  1021.         _G["eCastingBar"..frame.."_Outline"]:Show()
  1022.     end
  1023. end
  1024.  
  1025. --[[ Toggle enabled state. ]]--
  1026.  
  1027. function eCastingBar_checkEnabled()
  1028.   for index, option in pairs(frameSuffixes) do
  1029.     if (eCastingBar_Saved[option.."Enabled"] == 1) then
  1030.         eCastingBar_Enable(option)
  1031.     else
  1032.       eCastingBar_Disable(option)
  1033.     end
  1034.   end
  1035.  
  1036.   for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  1037.     if (eCastingBar_Saved.MirrorEnabled == 1) then
  1038.         if( eCastingBar_Saved.MirrorLocked == 0 ) then 
  1039.         -- yes, lets show the outline
  1040.         _G["eCastingBarMirror_Outline"]:Show()        
  1041.       end      
  1042.     else
  1043.       if( eCastingBar_Saved.MirrorLocked == 0 ) then
  1044.         -- yes, lets hide the outline
  1045.         _G["eCastingBarMirror_Outline"]:Hide()
  1046.       end
  1047.     end
  1048.   end
  1049. end
  1050.  
  1051. --[[-------------------------------------------
  1052.     Functions for using the Texture
  1053. -------------------------------------------]]--
  1054.  
  1055. --[[ Toggle enabled state. ]]--
  1056.  
  1057. function eCastingBar_checkTextures()
  1058.   for index, option in pairs(frameSuffixes) do
  1059.     if eCastingBar_Saved[option.."Texture"] == nil then
  1060.         eCastingBar_Saved[option.."Texture"] = "Perl"
  1061.     end
  1062.     if eCastingBar_Saved[option.."Texture"] == "Halycon" then
  1063.         eCastingBar_Saved[option.."Texture"] = "Halcyon"
  1064.     end
  1065.     _G["eCastingBar"..option.."StatusBarTexture"]:SetTexture( CASTING_BAR_TEXTURES[eCastingBar_Saved[option.."Texture"]] )
  1066.     _G["eCastingBar"..option.."StatusBarTexture"]:SetWidth(20)
  1067.     _G["eCastingBar"..option.."StatusBarTexture"]:SetHeight(10)
  1068.     _G["eCastingBar"..option.."StatusBarTexture"]:SetHorizTile(True)
  1069.     _G["eCastingBar"..option.."StatusBarTexture"]:SetVertTile(True)
  1070.     _G["eCastingBar"..option.."ExampleStatusBarTexture"]:SetTexture( CASTING_BAR_TEXTURES[eCastingBar_Saved[option.."Texture"]] )
  1071.     _G["eCastingBar"..option.."ExampleStatusBarText"]:SetText( eCastingBar_Saved[option.."Texture"] )
  1072.     _G["eCastingBar"..option.."ExampleStatusBarTexture"]:SetHorizTile(True)
  1073.     _G["eCastingBar"..option.."ExampleStatusBarTexture"]:SetVertTile(True)
  1074.  
  1075.   end
  1076.  
  1077.   for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  1078.     if eCastingBar_Saved.MirrorTexture == nil then
  1079.         eCastingBar_Saved.MirrorTexture = "Perl"
  1080.     end
  1081.     if eCastingBar_Saved.MirrorTexture == "Halycon" then
  1082.         eCastingBar_Saved.MirrorTexture = "Halcyon"
  1083.     end
  1084.     _G["eCastingBarMirror"..index.."StatusBarTexture"]:SetTexture( CASTING_BAR_TEXTURES[eCastingBar_Saved.MirrorTexture] )
  1085.     _G["eCastingBarMirror"..index.."StatusBarTexture"]:SetWidth(20)
  1086.     _G["eCastingBarMirror"..index.."StatusBarTexture"]:SetHeight(10)
  1087.     _G["eCastingBarMirror"..index.."StatusBarTexture"]:SetHorizTile(True)
  1088.     _G["eCastingBarMirror"..index.."StatusBarTexture"]:SetVertTile(True)
  1089.  
  1090.   end
  1091.   eCastingBarMirrorExampleStatusBarTexture:SetTexture( CASTING_BAR_TEXTURES[eCastingBar_Saved.MirrorTexture] )
  1092.   eCastingBarMirrorExampleStatusBarText:SetText(eCastingBar_Saved.MirrorTexture)
  1093.   eCastingBarMirrorExampleStatusBarTexture:SetHorizTile(True)
  1094.   eCastingBarMirrorExampleStatusBarTexture:SetVertTile(True)
  1095.  
  1096. end
  1097.  
  1098. function eCastingBar_setColor(colorFrame)
  1099.     if colorFrame == "SpellColor" or colorFrame == "ChannelColor" then
  1100.         local   Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[colorFrame])
  1101.     eCastingBarExampleStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  1102.     if (eCastingBar.casting) then
  1103.       local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved.SpellColor)
  1104.           eCastingBarStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  1105.         elseif (eCastingBar.channeling) then
  1106.             local   Red, Green, Blue, Alpha = unpack(eCastingBar_Saved.ChannelColor)
  1107.         eCastingBarStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  1108.     end
  1109.     elseif colorFrame == "TargetBarSpellColor" or colorFrame == "TargetBarChannelColor" then
  1110.         local   Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[colorFrame])
  1111.     eCastingBarTargetBarExampleStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  1112.     elseif colorFrame == "FocusBarSpellColor" or colorFrame == "FocusBarChannelColor" then
  1113.         local   Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[colorFrame])
  1114.     eCastingBarFocusBarExampleStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  1115.     else
  1116.         local   Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[colorFrame])
  1117.     eCastingBarMirrorExampleStatusBar:SetStatusBarColor( Red, Green, Blue, Alpha )
  1118.         local timer = strupper(gsub(colorFrame, "Color", ""))
  1119.       for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  1120.             local frame = _G["eCastingBarMirror"..index];
  1121.             if ( frame:IsVisible() and (frame.timer == timer) ) then
  1122.                 local   Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[colorFrame])
  1123.             _G["eCastingBarMirror"..index.."StatusBar"]:SetStatusBarColor( Red, Green, Blue, Alpha )
  1124.         end
  1125.     end
  1126.   end
  1127. end
  1128.  
  1129. function eCastingBar_setIcons()
  1130.   for index, option in pairs(frameSuffixes) do
  1131.     if (eCastingBar_Saved[option.."IconPosition"] == nil) then
  1132.         eCastingBar_Saved[option.."IconPosition"] = "HIDDEN"
  1133.     end
  1134.     if (eCastingBar_Saved[option.."IconPosition"] == "LEFT") then
  1135.         _G["eCastingBar"..option.."StatusBarIcon"]:ClearAllPoints()
  1136.             _G["eCastingBar"..option.."StatusBarIcon"]:SetPoint("RIGHT", _G["eCastingBar"..option], "LEFT", -5)
  1137.             if _G["eCastingBar"..option].casting or _G["eCastingBar"..option].channeling then
  1138.                 _G["eCastingBar"..option.."StatusBarIcon"]:Show()
  1139.             end
  1140.         elseif (eCastingBar_Saved[option.."IconPosition"] == "RIGHT") then
  1141.         _G["eCastingBar"..option.."StatusBarIcon"]:ClearAllPoints()
  1142.             _G["eCastingBar"..option.."StatusBarIcon"]:SetPoint("LEFT", _G["eCastingBar"..option], "RIGHT", 5)
  1143.             if _G["eCastingBar"..option].casting or _G["eCastingBar"..option].channeling then
  1144.                 _G["eCastingBar"..option.."StatusBarIcon"]:Show()
  1145.             end
  1146.         else
  1147.             _G["eCastingBar"..option.."StatusBarIcon"]:Hide()
  1148.         end
  1149.   end
  1150. end
  1151.  
  1152. function eCastingBar_checkTimeColors()
  1153.   for index, option in pairs(frameSuffixes) do
  1154.     local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[option.."TimeColor"])
  1155.     _G["eCastingBar"..option.."StatusBar_Time"]:SetTextColor(Red,Green,Blue, Alpha )
  1156.   end
  1157.   local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved.MirrorTimeColor)
  1158.   for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  1159.     _G["eCastingBarMirror"..index.."StatusBar_Time"]:SetTextColor(Red,Green,Blue, Alpha )
  1160.   end
  1161. end
  1162.  
  1163. function eCastingBar_setDelayColor()
  1164.   for index, option in pairs(frameSuffixes) do
  1165.     local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[option.."DelayColor"])
  1166.     _G["eCastingBar"..option.."StatusBar_Delay"]:SetTextColor(Red,Green,Blue, Alpha )
  1167.   end
  1168. end
  1169.  
  1170. --[[ sets up the flash to look cool ]]--
  1171.  
  1172. --(thanks goes to kaitlin for the code used while resting).
  1173.  
  1174. function eCastingBar_checkFlashBorderColors()
  1175.     local frmFrame = "eCastingBarFlash"
  1176.     local intIndex = 0
  1177.     local strBorder = ""
  1178.  
  1179.   for index, option in pairs(frameSuffixes) do
  1180.     local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved[option.."FlashBorderColor"])
  1181.    
  1182.     -- for each border in eCastingBar__FlashBorders set the color to gold.
  1183.     for intIndex, strBorder in pairs(eCastingBar__FlashBorders) do
  1184.       _G[ "eCastingBar"..option.."Flash_"..strBorder ]:SetVertexColor( Red, Green, Blue, Alpha )   
  1185.     end
  1186.   end
  1187.    
  1188.   for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  1189.     local Red, Green, Blue, Alpha = unpack(eCastingBar_Saved.MirrorFlashBorderColor)
  1190.     for intIndex, strBorder in pairs(eCastingBar__FlashBorders) do
  1191.       _G[ "eCastingBarMirror"..index.."Flash_"..strBorder ]:SetVertexColor( Red, Green, Blue, Alpha )  
  1192.     end
  1193.   end
  1194. end
  1195.  
  1196.  
  1197. -- Sets the width and height of the casting bar
  1198.  
  1199. function eCastingBar_SetSize()
  1200.   local width, height, bottom, left, bar
  1201.   for index, option in pairs(frameSuffixes) do
  1202.     -- check boundaries
  1203.     if (eCastingBar_Saved[option.."Width"] < CASTING_BAR_SLIDER_WIDTH_MIN) then
  1204.       width = CASTING_BAR_SLIDER_WIDTH_MIN
  1205.     elseif (eCastingBar_Saved[option.."Width"] > CASTING_BAR_SLIDER_WIDTH_MAX ) then
  1206.       width = CASTING_BAR_SLIDER_WIDTH_MAX
  1207.     else
  1208.       width = eCastingBar_Saved[option.."Width"]
  1209.     end
  1210.    
  1211.     if (eCastingBar_Saved[option.."Height"] > CASTING_BAR_SLIDER_HEIGHT_MAX) then
  1212.       height = CASTING_BAR_SLIDER_HEIGHT_MAX
  1213.     elseif (eCastingBar_Saved[option.."Height"] < CASTING_BAR_SLIDER_HEIGHT_MIN ) then
  1214.       height = CASTING_BAR_SLIDER_HEIGHT_MIN
  1215.     else
  1216.       height = eCastingBar_Saved[option.."Height"]
  1217.     end
  1218.    
  1219.     left = eCastingBar_Saved[option.."Left"]
  1220.     bottom = eCastingBar_Saved[option.."Bottom"]
  1221.    
  1222.     --[[
  1223.     if (eCastingBar_Saved[option.."Left"] < 0) then
  1224.       left = 0;
  1225.     else
  1226.       left = eCastingBar_Saved[option.."Left"];
  1227.     end
  1228.    
  1229.     if (eCastingBar_Saved[option.."Bottom"] < 0 ) then
  1230.       bottom = 0;;
  1231.     else
  1232.       bottom = eCastingBar_Saved[option.."Bottom"];
  1233.     end
  1234.     ]]--
  1235.    
  1236.     _G["eCastingBar"..option]:SetWidth(width)
  1237.     _G["eCastingBar"..option]:SetHeight(height)
  1238.    
  1239.     _G["eCastingBar"..option.."Background"]:SetWidth(width - 9)
  1240.     _G["eCastingBar"..option.."Background"]:SetHeight(height - 10)
  1241.    
  1242.     _G["eCastingBar"..option.."Flash"]:SetWidth(width)
  1243.     _G["eCastingBar"..option.."Flash"]:SetHeight(height)
  1244.    
  1245.     _G["eCastingBar"..option.."StatusBar"]:SetWidth(width - 9)
  1246.     _G["eCastingBar"..option.."StatusBar"]:SetHeight(height - 10)
  1247.  
  1248.     _G["eCastingBar"..option.."StatusBarIcon"]:SetWidth(height - 6)
  1249.     _G["eCastingBar"..option.."StatusBarIcon"]:SetHeight(height - 6)
  1250.    
  1251.     _G["eCastingBar"..option.."_Outline"]:SetWidth(width)
  1252.     _G["eCastingBar"..option.."_Outline"]:SetHeight(height)
  1253.     _G["eCastingBar"..option.."_Outline"]:ClearAllPoints()
  1254.     _G["eCastingBar"..option.."_Outline"]:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left, bottom )
  1255.    
  1256.     _G["eCastingBar"..option.."Flash_TOP"]:SetWidth(width - 24)
  1257.     _G["eCastingBar"..option.."Flash_BOTTOM"]:SetWidth(width - 24)
  1258.     _G["eCastingBar"..option.."Flash_LEFT"]:SetHeight(height - 24)
  1259.     _G["eCastingBar"..option.."Flash_RIGHT"]:SetHeight(height - 24)
  1260.    
  1261.     _G["eCastingBar"..option.."StatusBarSpark"]:SetHeight(height + 13)
  1262.    
  1263.     _G["eCastingBar"..option.."StatusBarText"]:SetWidth(width - 49)
  1264.     _G["eCastingBar"..option.."StatusBarText"]:SetHeight(height + 13)
  1265.    
  1266.     -- set the font size
  1267.     local fontName, _, fontFlags = _G["eCastingBar"..option.."StatusBarText"]:GetFont()
  1268.         _G["eCastingBar"..option.."StatusBarText"]:SetFont(fontName, eCastingBar_Saved[option.."FontSize"], fontFlags)
  1269.         _G["eCastingBar"..option.."StatusBar_Time"]:SetFont(fontName, eCastingBar_Saved[option.."FontSize"], fontFlags)
  1270.  
  1271.         -- set the Alpha
  1272.         local newAlpha = (eCastingBar_Saved[option.."Alpha"]/100)
  1273.         local Red, Green, Blue, Alpha = _G["eCastingBar"..option]:GetBackdropColor()
  1274.         _G["eCastingBar"..option]:SetBackdropColor(Red, Green, Blue, newAlpha)
  1275.         _G["eCastingBar"..option.."Background"]:SetAlpha(newAlpha)
  1276.         Red, Green, Blue, Alpha = _G["eCastingBar"..option.."_Outline"]:GetBackdropColor()
  1277.         _G["eCastingBar"..option.."_Outline"]:SetBackdropColor(Red, Green, Blue, newAlpha)
  1278.   end
  1279.  
  1280.   for index = 1, MIRRORTIMER_NUMTIMERS, 1 do
  1281.    
  1282.     -- check boundaries
  1283.     if (eCastingBar_Saved.MirrorWidth < CASTING_BAR_SLIDER_WIDTH_MIN) then
  1284.       width = CASTING_BAR_SLIDER_WIDTH_MIN
  1285.     elseif (eCastingBar_Saved.MirrorWidth > CASTING_BAR_SLIDER_WIDTH_MAX ) then
  1286.       width = CASTING_BAR_SLIDER_WIDTH_MAX
  1287.     else
  1288.       width = eCastingBar_Saved.MirrorWidth
  1289.     end
  1290.    
  1291.     if (eCastingBar_Saved.MirrorHeight > CASTING_BAR_SLIDER_HEIGHT_MAX) then
  1292.       height = CASTING_BAR_SLIDER_HEIGHT_MAX
  1293.     elseif (eCastingBar_Saved.MirrorHeight < CASTING_BAR_SLIDER_HEIGHT_MIN ) then
  1294.       height = CASTING_BAR_SLIDER_HEIGHT_MIN
  1295.     else
  1296.       height = eCastingBar_Saved.MirrorHeight
  1297.     end
  1298.    
  1299.     left = eCastingBar_Saved.MirrorLeft
  1300.     bottom = eCastingBar_Saved.MirrorBottom
  1301.    
  1302.     --[[
  1303.     if (eCastingBar_Saved.MirrorLeft < 0) then
  1304.       left = 0
  1305.     else
  1306.       left = eCastingBar_Saved.MirrorLeft
  1307.     end
  1308.    
  1309.     if (eCastingBar_Saved.MirrorBottom < 0 ) then
  1310.       bottom = 0
  1311.     else
  1312.       bottom = eCastingBar_Saved.MirrorBottom
  1313.     end
  1314.     ]]--
  1315.    
  1316.     _G["eCastingBarMirror"..index]:SetWidth(width)
  1317.     _G["eCastingBarMirror"..index]:SetHeight(height)
  1318.    
  1319.     _G["eCastingBarMirror"..index.."Background"]:SetWidth(width - 9)
  1320.     _G["eCastingBarMirror"..index.."Background"]:SetHeight(height - 10)
  1321.    
  1322.     _G["eCastingBarMirror"..index.."Flash"]:SetWidth(width)
  1323.     _G["eCastingBarMirror"..index.."Flash"]:SetHeight(height)
  1324.    
  1325.     _G["eCastingBarMirror"..index.."StatusBar"]:SetWidth(width - 9)
  1326.     _G["eCastingBarMirror"..index.."StatusBar"]:SetHeight(height - 10)
  1327.    
  1328.     _G["eCastingBarMirror_Outline"]:SetWidth(width)
  1329.     _G["eCastingBarMirror_Outline"]:SetHeight(height)
  1330.     _G["eCastingBarMirror_Outline"]:ClearAllPoints()
  1331.     _G["eCastingBarMirror_Outline"]:SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", left, bottom )
  1332.    
  1333.     _G["eCastingBarMirror"..index.."Flash_TOP"]:SetWidth(width - 24)
  1334.     _G["eCastingBarMirror"..index.."Flash_BOTTOM"]:SetWidth(width - 24)
  1335.     _G["eCastingBarMirror"..index.."Flash_LEFT"]:SetHeight(height - 24)
  1336.     _G["eCastingBarMirror"..index.."Flash_RIGHT"]:SetHeight(height - 24)
  1337.    
  1338.     _G["eCastingBarMirror"..index.."StatusBarSpark"]:SetHeight(height + 13)
  1339.    
  1340.     _G["eCastingBarMirror"..index.."StatusBarText"]:SetWidth(width - 49)
  1341.     _G["eCastingBarMirror"..index.."StatusBarText"]:SetHeight(height + 13)
  1342.    
  1343.     -- set the font size
  1344.     local fontName, _, fontFlags = _G["eCastingBarMirror"..index.."StatusBarText"]:GetFont()
  1345.         _G["eCastingBarMirror"..index.."StatusBarText"]:SetFont(fontName, eCastingBar_Saved.MirrorFontSize, fontFlags)
  1346.         _G["eCastingBarMirror"..index.."StatusBar_Time"]:SetFont(fontName, eCastingBar_Saved.MirrorFontSize, fontFlags)
  1347.         -- set the Alpha
  1348.         local newAlpha = (eCastingBar_Saved.MirrorAlpha/100)
  1349.         local Red, Green, Blue, Alpha = _G["eCastingBarMirror"..index]:GetBackdropColor()
  1350.         _G["eCastingBarMirror"..index]:SetBackdropColor(Red, Green, Blue, newAlpha)
  1351.         _G["eCastingBarMirror"..index.."Background"]:SetAlpha(newAlpha)
  1352.         Red, Green, Blue, Alpha = eCastingBarMirror_Outline:GetBackdropColor()
  1353.         eCastingBarMirror_Outline:SetBackdropColor(Red, Green, Blue, newAlpha)
  1354.   end
  1355. end
  1356.  
  1357. function eCastingBar_Copy_Table(src, dest)
  1358.     for index, value in pairs(src) do
  1359.         if (type(value) == "table") then
  1360.             dest[index] = {};
  1361.             eCastingBar_Copy_Table(value, dest[index]);
  1362.         else
  1363.             dest[index] = value;
  1364.         end
  1365.     end
  1366. end
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » eCastingBar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off