Thread Tools Display Modes
07-24-13, 11:51 AM   #1
MadMilitia
A Kobold Labourer
Join Date: Jul 2013
Posts: 1
JukedParty - Personal modifications - Help Request

Hello,

JukedParty is a preexisting addon that I've taken the liberty of looking at for my multiboxing purposes. In native design it displays a list of abilities fed through a configuration file to the player which is then tripped if a player inside the player's party uses that ability. It creates a cooldown mask and starts the timer to refresh the ability. Thank you Robrman for this addon!

Because I multibox my requirements are slightly different for this addon. It needs to:

1. Work only for the designated character names I feed it.
2. Do not display abilities for classes that have those abilities. This requirement requires that the configuration file contain a new class parameter to associate each listed ability.

The requirements I added myself but now a problem has surfaced. When filtering out by class the abilities, I get nothing. I added prints to see what was happening in the logic when a match was found, when it wasn't found and when the bar was being given the new btn object. All of the prints suggest to me that it is pushing the new btn to the bar but the bar shows nothing. If I remove the class check logic (by commenting it and reloading), the bar updates with the ability list proper.

Attached is the code with my modifications.

Config file:

Code:
--CHANGELOG:
--Modified {spellID=8177, time=22, prio=false},--Grounding Totem
--Added {spellID=30283, time=20, prio=false},--Shadowfury (v1.3.5)
--Modified {spellID=31224, time=90, prio=false},--Cloak of Shadows (v1.3.5)
--Modified {spellID=74001, time=90, prio=false},--Combat Readiness (v1.3.5)
--Added {spellID=98008, time=180, prio=false},--Spirit Link Totem (v1.3.4)
--Thanks to Pielo for these
--Added {spellID=1719, time=300, prio=false},--Recklessness(Arms) (v1.3.4)
--Added {spellID=51271, time=60, prio=false},--Pillar of Frost (v1.3.4)
--Added {spellID=31884, time=180, prio=false},--Avenging Wrath (v1.3.4)
--Added {spellID=85730, time=120, prio=false},--Deadly Calm (v1.3.4)
--Added {spellID=1953, time=15, prio=false},--Blink(v1.3.4)
--Added {spellID=20511, time=120, prio=false},--Intimidating Shout(v1.3.4) 
--Reordered the table (v1.3.4)
--Added  {spellID=23920, time=25, prio=false},--Spell Reflection (v1.3.3)

spell_table = {

{spellID=100,  time=12,     prio=false, class="Warrior"}, -- Charge 
{spellID=6552, time=10,     prio=true,  class="Warrior"}, -- Pummel
{spellID=102060, time=40,   prio=false, class="Warrior"}, -- Disrupting Shout
{spellID=676, time=60,      prio=false, class="Warrior"}, -- Disarm
{spellID=20511, time=120,   prio=false, class="Warrior"}, -- Intimidating Shout
{spellID=46924, time=75,    prio=false, class="Warrior"}, -- Bladestorm (glyphed)
{spellID=1719, time=300,    prio=false, class="Warrior"}, -- Recklessness
{spellID=118038, time=120,  prio=false, class="Warrior"}, -- Die by the Sword
{spellID=114029, time=30,   prio=false, class="Warrior"}, -- Safeguard
{spellID=871,    time=180,  prio=false, class="Warrior"}, -- Shieldwall
{spellID=23920,  time=25,   prio=false, class="Warrior"}, -- Spell Reflection
{spellID=64382,  time=300,  prio=false, class="Warrior"}, -- Shattering Throw
{spellID=97462,  time=180,  prio=false, class="Warrior"}, -- Rallying Cry
{spellID=18499,  time=30,   prio=false, class="Warrior"}, -- Berserker Rage
{spellID=6544,   time=30,   prio=false, class="Warrior"}, -- Heroic Leap
{spellID=107574, time=180,  prio=false, class="Warrior"}, -- Avatar
{spellID=12328,  time=10,   prio=false, class="Warrior"}, -- Sweeping Strikes
{spellID=114192, time=180,  prio=false, class="Warrior"}, -- Mocking Banner
{spellID=114203, time=180,  prio=false, class="Warrior"}, -- Demoralizing Banner
{spellID=114207, time=180,  prio=false, class="Warrior"}, -- Skull Banner


{spellID=34490,  time=24,  prio=true,   class="Hunter"}, -- Silencing Shot
{spellID=19503,  time=30,  prio=false,  class="Hunter"}, -- Scatter Shot
{spellID=19263,  time=60,  prio=false,  class="Hunter"}, -- Deterrence (glyphed)
{spellID=23989,  time=300, prio=false,  class="Hunter"}, -- Readiness
{spellID=51753,  time=60,  prio=false,  class="Hunter"}, -- Camouflage
{spellID=109248, time=45,  prio=false,  class="Hunter"}, -- Binding Shot
{spellID=781,    time=15,  prio=false,  class="Hunter"}, -- Disengage
{spellID=53271,  time=45,  prio=false,  class="Hunter"}, -- Master's Call
{spellID=117050, time=15,  prio=false,  class="Hunter"}, -- Glaive Toss
{spellID=1543,   time=20,  prio=false,  class="Hunter"}, -- Flare
{spellID=91644,   time=30,  prio=false, class="Hunter"}, -- Bird Disarm
{spellID=34477,  time=30,  prio=false,  class="Hunter"}, -- Misdirection
{spellID=3045,   time=300, prio=false,  class="Hunter"}, -- Rapid Fire
{spellID=121818,  time=300, prio=false, class="Hunter"}, -- Stampede
{spellID=13813,  time=28, prio=false,   class="Hunter"}, -- Explosive Trap -- launcher 82939
{spellID=1499,   time=28, prio=false,   class="Hunter"}, -- Freezing Trap -- launcher 60192
{spellID=13809,  time=28, prio=false,   class="Hunter"}, -- Ice Trap --launcher 82941
{spellID=34600,  time=28, prio=false,   class="Hunter"}, -- Snake Trap --launcher 


{spellID=57994,  time=12,  prio=true,  class="Shaman"},  -- Wind Shear
{spellID=51514,  time=45,  prio=false, class="Shaman"}, -- Hex (glyphed)
{spellID=98008,  time=180, prio=false, class="Shaman"}, -- Spirit Link Totem
{spellID=8177,   time=25,  prio=false, class="Shaman"}, -- Grounding Totem
{spellID=16190,  time=180, prio=false, class="Shaman"}, -- Mana Tide Totem

{spellID=108269, time=180, prio=false, class="Shaman"}, -- Capacitator Totem
{spellID=108273, time=60,  prio=false, class="Shaman"}, -- Windwalk Totem
{spellID=120668, time=300, prio=false, class="Shaman"}, -- Stormlash Totem
{spellID=3600,   time=30,  prio=false, class="Shaman"}, -- Earthbind Totem
{spellID=8143,   time=60,  prio=false, class="Shaman"}, -- Tremor Totem
{spellID=2062,   time=300, prio=false, class="Shaman"}, -- Earth Elemental Totem
{spellID=108270, time=60,  prio=false, class="Shaman"}, -- Stone Bulwark Totem
{spellID=2894,   time=300, prio=false, class="Shaman"}, -- Fire Elemental Totem
{spellID=5394,   time=30,  prio=false, class="Shaman"}, -- Healing Stream Totem
{spellID=108280, time=180, prio=false, class="Shaman"}, -- Healing Tide Totem


{spellID=16188,  time=90,  prio=false, class="Shaman"}, -- Ancestral Swiftness
{spellID=77130,  time=8,   prio=false, class="Shaman"}, -- Purify Spirit
{spellID=73680,  time=15,  prio=false, class="Shaman"}, -- Unleash Elements
{spellID=79206,  time=120, prio=false, class="Shaman"}, -- Spiritwalker's Grace

{spellID=114049, time=120, prio=false, class="Shaman"}, -- Ascendance
{spellID=2825,   time=300, prio=false, class="Shaman"}, -- Bloodlust
{spellID=108285, time=120, prio=false, class="Shaman"}, -- Call of the Elements
{spellID=73920,  time=600, prio=false, class="Shaman"}, -- Healing Rain



}


JukedParty:

Code:
--[[--------------------------------------------------
--JukedParty by Robrman, Inspired by Kollektiv's InterruptBar
--Version 1.3.7
CHANGELOG:
--Updated for 4.3, added some new spells
--Fixed Hidden off smart on (spell icons were stacking)
--Some of the cooldowns may have changed, if they have and I didnt fix them please let me know.
--Fixed for 4.2, added shadowfury, fixed cloak of shadows and combat readiness CD
--Cleaned up some of the code
--Fixed moving the frames
--Fixed spell reflect cd
--Updated for 4.1
--Fixed some issues with profiles, still could be more
--Added profiles, i've tested it works perfectly fine from what i've tried - 
--FINALLY added a GUI for the options.  Use "/JukedParty gui" or "/JukedParty opts" or "/JukedParty config" 
--Added Silencing shot to be reset with Readiness
--Added Readiness resetting Scatter Shot and Deterrence, I probably missed some..its 5 am nobody on to help me test fully, sorry if its incomplete post and i'll fix it
--Cleaned up some of the code, fixed some errors with repositioning
--Added individual locking, hiding and smart modes, still possibly buggy
--Fixed moving, probably still some work to be done there
--Cleaned up the help menu a bit, feedback is appreciated
--Added scaling for main bar and prio bar individually
--Fixed possible problem with Gnaw if used by a transformed ghoul (Thanks Damnationx)
--Fixed Death Coil cooldown to account for Warlock 4 piece bonus -30 seconds (Thanks Damnationx)
--Fixed cooldown timer restarting (if same CD is popped, restart timer. Thanks Damnationx)
--Added Inner Focus   {spellID=89485, time=45, prio=false},--Inner Focus     (Thanks Sazalolz, cant believe i missed it)
--Added /JukedParty prioonly   this will ONLY display cooldowns for spells marked with prio=true
--Added noCD option to disable the numeric cooldown from JukedParty 
--Fixed some cooldown durations(Thanks Sazalolz for pointing it out)
--Externalized the spell table(Thanks Sazalolz for the suggestion)
--Added test for all modes
--Added a fix for some versions of omniCC
--Fixed Rebuke spellID
--Addon can now be accessed from /JukedParty   /jd   and   /ib(kept this cause i kept typing it by accident)
--Added the option to grow the bars upward from the anchor /JukedParty
----------------------------------------------------]]
JukedPartyRealm = GetCVar("realmName");
JukedPartyChar = UnitName("player");
CharIndex=JukedPartyChar.." - "..JukedPartyRealm
JukedPartyDB=JukedPartyDB or {}
JukedPartyDB["CharsUse"]=JukedPartyDB["CharsUse"] or {}
JukedPartyDB["Default"]= JukedPartyDB["Default"] or { scale = 1,scale2=1 , hidden = false,hidden2=false, smart=false, smartPrio=false,prio = false, cols=6, colsPrio=6, arenaOnly=false, bgOnly=false, lock = false,growUp=1,growLeft=1, noCD=false,prioOnly=false,}
JukedPartyDB[CharIndex] = JukedPartyDB[CharIndex] or JukedPartyDB["Default"]--{ scale = 1,scale2=1 , hidden = false,hidden2=false, smart=false, smartPrio=false,prio = false, cols=6, colsPrio=6, arenaOnly=false, bgOnly=false, lock = false,growUp=1,growLeft=1, noCD=false,prioOnly=false,}
for k,v in pairs(JukedPartyDB) do
	if not (type(JukedPartyDB[k]) == "table" ) then 
		JukedPartyDB[k]=nil
	elseif (k=="Position" and (JukedPartyDB["Position"]["scale2"]==nil)) then 
		JukedPartyDB[k]=nil
	end
end
if (JukedPartyDB["CharsUse"][CharIndex]) then
	CharIndex=JukedPartyDB["CharsUse"][CharIndex]
else
	JukedPartyDB["CharsUse"][CharIndex]=CharIndex
end

StaticPopupDialogs["INFO"] = {
  text = "Ability: %s",
  button1 = "Ok",
  timeout = 0,
}

local myClassName, engClass, classIndex = UnitClass("player")




local abilities = {}
local order
local arena=false
local bg=false
local band = bit.band
local spell_table=spell_table
--[[
TO ADD:
-- Smoke bomb once it can be tracked
--]]
-----------------------------------------------------
-----------------------------------------------------
if spell_table==nil then ChatFrame1:AddMessage("NOT LOADED",0,1,0) end
for k,spell in ipairs(spell_table) do
	local name,_,spellicon = GetSpellInfo(spell.spellID)	
	abilities[spell.spellID] = { icon = spellicon, duration = spell.time }
end

local frame
local bar
local bar2

local x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
local x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
local y2 = 0
local count2 = 0
local count=0
local y=0
local totalIcons=0
local GetTime = GetTime
local ipairs = ipairs
local pairs = pairs
local select = select
local floor = floor
local band = bit.band
local GetSpellInfo = GetSpellInfo


local GROUP_UNITS = bit.bor(0x00000010, 0x00000400)

local activetimers = {}

local size = 0
local function getsize()
	size = 0
	for k in pairs(activetimers) do
		size = size + 1
	end
end

local function isInBG()
	local a,type = IsInInstance()
	if (type == "pvp") then
		return true
	end
	return false
end

local function isInArena()
	local _,type = IsInInstance()
	if (type == "arena") then
		return true
	end
	return false
	
end


local function isPrio(ability)
	for _,v in ipairs(spell_table) do
		if v.spellID==ability then--find ability in table
			return v.prio--return prio status for ability
		end
	end
	return false
end

local function getTotalPrio(from)
	local ret=0
	if JukedPartyDB[CharIndex].prio or from then
		for _,v in ipairs(spell_table) do
			if v.prio then
				ret=ret+1
			end
		end
	end
	return ret
end

local function getTotalMain()
	local ret=0
	if JukedPartyDB[CharIndex].prio then
		for _,v in ipairs(spell_table) do
			if not v.prio then
				ret=ret+1
			end
		end
		return ret
	end
	return #(spell_table)
end

local function JukedParty_AddIcons()

	DEFAULT_CHAT_FRAME:AddMessage("Adding icons!");


	for _,ability in ipairs(spell_table) do--for all spells in spell table


		-- Only do if not the class I'm currently playing.
		if not (ability.class == myClassName) then 

			print("Not my class! Adding!")
		

			local btn = CreateFrame("Frame",nil,bar)
			btn:SetWidth(30)--create the frame and set the dimensions
			btn:SetHeight(30)
		
			if JukedPartyDB[CharIndex].prio and isPrio(ability.spellID) then
				btn:SetPoint("CENTER",bar,"CENTER",x2,y2)
			else
				btn:SetPoint("CENTER",bar,"CENTER",x,y)
			end
			
			btn:SetFrameStrata("LOW")
			local cd = CreateFrame("Cooldown",nil,btn)
			cd.noomnicc = not JukedPartyDB[CharIndex].noCD
			cd.noOCC = not JukedPartyDB[CharIndex].noCD
			cd.noCooldownCount = not JukedPartyDB[CharIndex].noCD
		
			cd:SetAllPoints(true)
			cd:SetFrameStrata("LOW")
			cd:Hide()
		
			local texture = btn:CreateTexture(nil,"BACKGROUND")
			texture:SetAllPoints(true)
			texture:SetTexture(abilities[ability.spellID].icon)
			texture:SetTexCoord(0.07,0.9,0.07,0.90)
	
			local text = cd:CreateFontString(nil,"ARTWORK")
			text:SetFont(STANDARD_TEXT_FONT,18,"OUTLINE")
			text:SetTextColor(1,1,0,1)
			text:SetPoint("LEFT",btn,"LEFT",1,0)
			
			btn.texture = texture
			btn.text = text
			btn.duration = abilities[ability.spellID].duration
			btn.cd = cd
		
			if JukedPartyDB[CharIndex].prio and isPrio(ability.spellID) then
				bar2[ability.spellID] = btn
				if (JukedPartyDB[CharIndex].prioOnly and not isPrio(ability.spellID)) then bar2[ability.spellID]:Hide() end
				x2 = x2 + 30 * JukedPartyDB[CharIndex].growLeft
				count2 = count2 + 1
				totalIcons = totalIcons + 1
				if count2 >= JukedPartyDB[CharIndex].colsPrio and JukedPartyDB[CharIndex].colsPrio > 0 then
					y2 = y2 - 30 * JukedPartyDB[CharIndex].growUp
					x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
					count2=0
				end
			else
				print("Adding btn to bar!")
				bar[ability.spellID] = btn
				if (JukedPartyDB[CharIndex].prioOnly and not isPrio(ability.spellID)) then bar[ability.spellID]:Hide() end
				x = x + 30 * JukedPartyDB[CharIndex].growLeft
				count = count + 1
				totalIcons = totalIcons + 1
				if count >= JukedPartyDB[CharIndex].cols and JukedPartyDB[CharIndex].cols > 0 then
					y = y - 30 * JukedPartyDB[CharIndex].growUp
					x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
					count=0
				end
			end
		
		else 

			print("My class! Doing nothing!")			

		end
	end
	x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
	count=0
	y=0
	active=0
	x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
	count2=0
	--ChatFrame1:AddMessage("Reset count2",0,1,0)
	y2=0

	print("Done!")
end

local function JukedParty_AddIcon(ability)
	if (JukedPartyDB[CharIndex].prioOnly and not isPrio(ability)) then return end
	if JukedPartyDB[CharIndex].prio and isPrio(ability) then
		if not bar2[ability]:IsVisible() then
			bar2[ability]:SetPoint("CENTER",bar2,x2,y2)
			bar2[ability]:Show()
			--ChatFrame1:AddMessage("ADDING PRIO "..ability.." x2 BEFORE="..x2.." count2: "..count2,0,1,0)
			x2 = x2 + 30 * JukedPartyDB[CharIndex].growLeft
			count2 = count2 + 1
			--ChatFrame1:AddMessage("ADDING PRIO "..ability.." x2 AFTER="..x2.." count2: "..count2,0,1,0)
			if count2 >= JukedPartyDB[CharIndex].colsPrio and JukedPartyDB[CharIndex].colsPrio > 0 then
				y2 = y2 - 30 * JukedPartyDB[CharIndex].growUp
				x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
				count2=0
				--ChatFrame1:AddMessage("Reset count2",0,1,0)
			end
		end
	else
		if not bar[ability]:IsVisible() then
			bar[ability]:SetPoint("CENTER",bar,x,y)
			bar[ability]:Show()
			x = x + 30 * JukedPartyDB[CharIndex].growLeft
			count = count + 1
			if count >= JukedPartyDB[CharIndex].cols and JukedPartyDB[CharIndex].cols > 0 then
				y = y - 30 * JukedPartyDB[CharIndex].growUp
				x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
				count=0
			end
		end
	end
		local main=getTotalMain()
	if JukedPartyDB[CharIndex].cols == 0 then
		bar:SetWidth(30*main)
	else
		bar:SetWidth(30*JukedPartyDB[CharIndex].cols)
	end
	local numprio=getTotalPrio()
	if JukedPartyDB[CharIndex].prio then
		if JukedPartyDB[CharIndex].colsPrio == 0 then
			bar2:SetWidth(30*numprio)
		else
			bar2:SetWidth(30*JukedPartyDB[CharIndex].colsPrio)
		end
	end
end


local function JukedParty_SavePosition()
	local point, _, relativePoint, xOfs, yOfs = bar:GetPoint()
	if not JukedPartyDB[CharIndex].Position then 
		JukedPartyDB[CharIndex].Position = {}
	end
	--first bar
	JukedPartyDB[CharIndex].Position.point = point
	JukedPartyDB[CharIndex].Position.relativePoint = relativePoint
	JukedPartyDB[CharIndex].Position.xOfs = xOfs
	JukedPartyDB[CharIndex].Position.yOfs = yOfs
	--second bar
	local point, _, relativePoint, xOfs, yOfs = bar2:GetPoint()
	JukedPartyDB[CharIndex].Position.point2 = point
	JukedPartyDB[CharIndex].Position.relativePoint2 = relativePoint
	JukedPartyDB[CharIndex].Position.xOfs2 = xOfs
	JukedPartyDB[CharIndex].Position.yOfs2 = yOfs
end

local function JukedParty_LoadPosition()
	if JukedPartyDB[CharIndex].Position then
		bar:SetPoint(JukedPartyDB[CharIndex].Position.point,UIParent,JukedPartyDB[CharIndex].Position.relativePoint,JukedPartyDB[CharIndex].Position.xOfs,JukedPartyDB[CharIndex].Position.yOfs)
		if JukedPartyDB[CharIndex].Position.point2 then
			bar2:SetPoint(JukedPartyDB[CharIndex].Position.point2,UIParent,JukedPartyDB[CharIndex].Position.relativePoint2,JukedPartyDB[CharIndex].Position.xOfs2,JukedPartyDB[CharIndex].Position.yOfs2)
		else
			bar2:SetPoint("CENTER", UIParent, "CENTER")
		end
	else
		bar:SetPoint("CENTER", UIParent, "CENTER")
		bar2:SetPoint("CENTER", UIParent, "CENTER")
	end
end

local function JukedParty_Repos()
	if (JukedPartyDB[CharIndex].bgOnly and not bg and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].bgOnly and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].arenaOnly and JukedPartyDB[CharIndex].bgOnly and not bg) then return end
	--[[if JukedPartyDB[CharIndex].smart then
		--x = -60
		x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
		count=0
		y=0
	end
	--x2 = -60
	if JukedPartyDB[CharIndex].smartPrio then
		x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
		count2 = 0
		ChatFrame1:AddMessage("Reset count2 REPOSFIRST****",0,1,0)
		y2 = 0
	end]]
	if not JukedPartyDB[CharIndex].smart then
		x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
		count=0
		y=0
		for _,v in ipairs(spell_table) do
			if not (JukedPartyDB[CharIndex].prio and isPrio(v.spellID)) then
				bar[v.spellID]:Hide()
				JukedParty_AddIcon(v.spellID)
				if JukedPartyDB[CharIndex].hidden and not activetimers[v.spellID] then
					bar[v.spellID]:Hide()
				end
			end
		end
	else 
		if JukedPartyDB[CharIndex].hidden then
			x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
			count=0
			y=0
		end
		for _,v in ipairs(spell_table) do
			if not(isPrio(v.spellID) and JukedPartyDB[CharIndex].prio) then
				bar[v.spellID]:Hide()
				if activetimers[v.spellID] then
					JukedParty_AddIcon(v.spellID)
				else 
					if JukedPartyDB[CharIndex].hidden then
						bar[v.spellID]:Hide()
					end
				end
			end
		end
	end
	if JukedPartyDB[CharIndex].prio then
		if not JukedPartyDB[CharIndex].smartPrio then
			x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
			count2 = 0
			--ChatFrame1:AddMessage("Reset count2 REPOSFIRST****",0,1,0)
			y2 = 0
			for _,v in ipairs(spell_table) do
				if JukedPartyDB[CharIndex].prio and isPrio(v.spellID) then
					bar2[v.spellID]:Hide()
					JukedParty_AddIcon(v.spellID)
					if JukedPartyDB[CharIndex].hidden2 and not activetimers[v.spellID] then
						bar2[v.spellID]:Hide()
					end
				end
			end
		else
			if JukedPartyDB[CharIndex].hidden2 then
				x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
				count2 = 0
				--ChatFrame1:AddMessage("Reset count2 REPOSFIRST****",0,1,0)
				y2 = 0
			end
			for _,v in ipairs(spell_table) do
				if JukedPartyDB[CharIndex].prio and isPrio(v.spellID) and JukedPartyDB[CharIndex].hidden2 then
					bar2[v.spellID]:Hide()
					if activetimers[v.spellID] then
						JukedParty_AddIcon(v.spellID)
					else
						if JukedPartyDB[CharIndex].hidden2 then
							bar2[v.spellID]:Hide()
						end
					end
				end
			end
		end
	end
end

local function JukedParty_UpdateBar()
	bar:SetScale(JukedPartyDB[CharIndex].scale)
	bar2:SetScale(JukedPartyDB[CharIndex].scale2)
	
	local main=getTotalMain()
	local numprio=getTotalPrio()
	if JukedPartyDB[CharIndex].cols == 0 then
		bar:SetWidth(30*main)
	else
		bar:SetWidth(30*JukedPartyDB[CharIndex].cols)
	end
	if JukedPartyDB[CharIndex].prio then
		if JukedPartyDB[CharIndex].colsPrio == 0 then
			bar2:SetWidth(30*numprio)
		else
			bar2:SetWidth(30*JukedPartyDB[CharIndex].colsPrio)
		end
	end
	if JukedPartyDB[CharIndex].prio then
		bar2:Show()
	end
	if not JukedPartyDB[CharIndex].prio then--if prio was disabled
		for _,v in ipairs(spell_table) do 
			if isPrio(v.spellID) and bar2[v.spellID] then--if spell is prio and on currently on bar2
				bar[v.spellID]=bar2[v.spellID] --move the spell back to bar1
			end
		end
		bar2:Hide()--hide bar2
	elseif JukedPartyDB[CharIndex].prio and table.getn(bar2) == 0 then--if prio is on and bar2 is empty
		for _,v in ipairs(spell_table) do
			if JukedPartyDB[CharIndex].prio and isPrio(v.spellID) then--if spell is prio and prio is on
				if bar[v.spellID] and not bar2[v.spellID] then
					bar2[v.spellID]=bar[v.spellID]--put spell on bar2
				end
			end
		end
	end
	--if bgonly mode is on, and not in a bg, or arenaonly and not in arena, or bgonly and arenaonly modes and not in bg or arena
	if (JukedPartyDB[CharIndex].bgOnly and not bg and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].bgOnly and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].arenaOnly and JukedPartyDB[CharIndex].bgOnly and not bg) then 
		for _,v in ipairs(spell_table) do
			if JukedPartyDB[CharIndex].prio and isPrio(v.spellID) then
				bar2[v.spellID]:Hide()--hide spells on prio and main bar
			else
				bar[v.spellID]:Hide()
			end
		end
		return
	end
	if JukedPartyDB[CharIndex].hidden or JukedPartyDB[CharIndex].hidden2 or JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio then
		if JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio then
			--x = -60--if smart, reset the icon positioning variables
			x = 15+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].cols/2)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
			count=0
			y=0
		--end
		--if JukedPartyDB[CharIndex].smartPrio then
			--x2 = -60
			x2 = 15+((JukedPartyDB[CharIndex].colsPrio/2)*-30*((JukedPartyDB[CharIndex].growLeft+1)/2))+((JukedPartyDB[CharIndex].colsPrio/2-1)*-30*((JukedPartyDB[CharIndex].growLeft-1)/2))
			y2 = 0
			count2 = 0
			--ChatFrame1:AddMessage("Reset count2 REPOS",0,1,0)
		end
		for _,v in ipairs(spell_table) do
			if JukedPartyDB[CharIndex].prio and isPrio(v.spellID) then
				if JukedPartyDB[CharIndex].hidden2 or JukedPartyDB[CharIndex].smartPrio then
					bar2[v.spellID]:Hide()--hide spells on bar2
				else
					bar2[v.spellID]:Show()
				end
				bar2[v.spellID].cd.noomnicc = not JukedPartyDB[CharIndex].noCD
				bar2[v.spellID].cd.noOCC = not JukedPartyDB[CharIndex].noCD--set correct flags to enable/disable omniCC 
				bar2[v.spellID].cd.noCooldownCount = not JukedPartyDB[CharIndex].noCD
				bar2[v.spellID]:SetParent(bar2)
			else	
				if JukedPartyDB[CharIndex].hidden or JukedPartyDB[CharIndex].smart then
					bar[v.spellID]:Hide()--hide spells on main bar
				else
					bar[v.spellID]:Show()
				end
				bar[v.spellID].cd.noomnicc = not JukedPartyDB[CharIndex].noCD
				bar[v.spellID].cd.noOCC = not JukedPartyDB[CharIndex].noCD--set correct flags to enable/disable omniCC 
				bar[v.spellID].cd.noCooldownCount = not JukedPartyDB[CharIndex].noCD
				bar[v.spellID]:SetParent(bar)
			end
		end
	else--if not hidden or smart
		for _,v in ipairs(spell_table) do
			if JukedPartyDB[CharIndex].prio and isPrio(v.spellID) then
				bar2[v.spellID]:Show() --show spell
				bar2[v.spellID].cd.noomnicc = not JukedPartyDB[CharIndex].noCD
				bar2[v.spellID].cd.noOCC = not JukedPartyDB[CharIndex].noCD--set correct flags to enable/disable omniCC 
				bar2[v.spellID].cd.noCooldownCount = not JukedPartyDB[CharIndex].noCD
				bar2[v.spellID]:SetParent(bar2)
			else
				bar[v.spellID]:Show() 
				bar[v.spellID].cd.noomnicc = not JukedPartyDB[CharIndex].noCD
				bar[v.spellID].cd.noOCC = not JukedPartyDB[CharIndex].noCD
				bar[v.spellID].cd.noCooldownCount = not JukedPartyDB[CharIndex].noCD
				bar[v.spellID]:SetParent(bar)
			end
		end
	end
	if JukedPartyDB[CharIndex].prioOnly then--if prio only
		for _,v in ipairs(spell_table) do
			if not isPrio(v.spellID) then--hide non-prio spells
				bar[v.spellID]:Hide()
			end
		end
	end
	if JukedPartyDB[CharIndex].lock then--if bar is locked, disable mouse
		bar:EnableMouse(false)
	else--else, enable mouse
		bar:EnableMouse(true)
	end
	if JukedPartyDB[CharIndex].lockPrio then
		bar2:EnableMouse(false)
	else
		bar2:EnableMouse(true)
	end
end

local function JukedParty_CreateBar()
	bar = CreateFrame("Frame", "JukedPartyMainBar", UIParent)
	bar:SetMovable(true)
	bar:SetWidth(120)
	bar:SetHeight(30)
	bar:SetClampedToScreen(true) 
	bar:SetScript("OnMouseDown",function(self,button) if button == "LeftButton" then self:StartMoving() end end)
	bar:SetScript("OnMouseUp",function(self,button) if button == "LeftButton" then self:StopMovingOrSizing() JukedParty_SavePosition() end end)
	bar:Show()

	bar2 = CreateFrame("Frame", "JukedPartyPrioBar", UIParent)
	bar2:SetMovable(true)
	bar2:SetWidth(120)
	bar2:SetHeight(30)
	bar2:SetClampedToScreen(true) 
	bar2:SetScript("OnMouseDown",function(self,button) if button == "LeftButton" then self:StartMoving() end end)
	bar2:SetScript("OnMouseUp",function(self,button) if button == "LeftButton" then self:StopMovingOrSizing() JukedParty_SavePosition() end end)
	bar2:Show()
	
	JukedParty_AddIcons()
	JukedParty_UpdateBar()
	JukedParty_LoadPosition()
end

local function JukedParty_UpdateText(text,cooldown)
if  JukedPartyDB[CharIndex].noCD then return end
	if cooldown < 100 then 
		if cooldown <= 0.5 then
			text:SetText("")
		elseif cooldown < 10 then
			text:SetFormattedText(" %d",cooldown)
		else
			text:SetFormattedText("%d",cooldown)
		end
	else
		local m=floor((cooldown+30)/60)
		text:SetFormattedText("%dm",m)
	end
	if cooldown < 6 then 
		text:SetTextColor(1,0,0,1)
	else 
		text:SetTextColor(1,1,0,1) 
	end
end

local function JukedParty_StopAbility(ref,ability)
	if (JukedPartyDB[CharIndex].hidden2 and isPrio(ability)) or (JukedPartyDB[CharIndex].hidden and not isPrio(ability)) then
		if ref then
			ref:Hide()
		else
			if isPrio(ability) and JukedPartyDB[CharIndex].prio then
				ref=bar2[ability]
			else
				ref=bar[ability]	
			end
		end
	end
	if activetimers[ability] then activetimers[ability] = nil end
	ref.text:SetText("")
	ref.cd:Hide()
	if (JukedPartyDB[CharIndex].hidden or JukedPartyDB[CharIndex].hidden2) and (JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio) then JukedParty_Repos() end
end

local time = 0
local function JukedParty_OnUpdate(self, elapsed)
	time = time + elapsed
	if time > 0.25 then
		getsize()
		for ability,ref in pairs(activetimers) do
			ref.cooldown = ref.start + ref.duration - GetTime()
			if ref.cooldown <= 0 then
				JukedParty_StopAbility(ref,ability)
			else 
				JukedParty_UpdateText(ref.text,floor(ref.cooldown+0.5))
			end
		end
		if size == 0 then frame:SetScript("OnUpdate",nil) end
		time = time - 0.25
	end
end

local function JukedParty_StartTimer(ref,ability)
	if (JukedPartyDB[CharIndex].bgOnly and not bg and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].bgOnly and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].arenaOnly and JukedPartyDB[CharIndex].bgOnly and not bg) then return end
	if JukedPartyDB[CharIndex].hidden or JukedPartyDB[CharIndex].hidden2 or JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio then
		ref:Show()
	end
	--if not activetimers[ability] then
		local duration
		activetimers[ability] = ref
		ref.cd:Show()
		ref.cd:SetCooldown(GetTime()-0.40,ref.duration)
		ref.start = GetTime()
		JukedParty_UpdateText(ref.text,ref.duration)
	--end
	frame:SetScript("OnUpdate",JukedParty_OnUpdate)
end

local function JukedParty_COMBAT_LOG_EVENT_UNFILTERED(...)
	local spellID, ability, useSecondDuration
	return function(_, eventtype, _,_, srcName, srcFlags, _,_, dstName, dstFlags,_, id)
	--ChatFrame1:AddMessage("FLAGS : "..srcFlags.."  "..srcName,0,1,0)
			local hex=band(srcFlags, 0x00000016)
		if ( (hex == 0x00000014 or hex == 0x00000012)  and (eventtype == "SPELL_CAST_SUCCESS" or eventtype == "SPELL_AURA_APPLIED")) then 
			spellID = id
		else
			return
		end



		if (not (srcName == "MyToon1" or srcName == "MyToon2" or srcName == "MyToon3")) then 
		
			return 
		
		end



		if spellID == 49376 then spellID = 16979; useSecondDuration = true end -- Feral Charge - Cat -> Feral Charge - Bear
		if spellID == 91797 then spellID = 91800; end
		if spellID == 52174 then spellID = 6544; end	-- Heroic Leap
		if spellID == 82939 then spellID = 13813; end -- Trap Launcer (Explosive)
		if spellID == 82941 then spellID = 13809; end -- Trap Launcer (Ice)
		if spellID == 60192 then spellID = 1499; end -- Trap Launcer (Freezing)

		if (JukedPartyDB[CharIndex].prioOnly and not isPrio(spellID)) then return end
		if (JukedPartyDB[CharIndex].bgOnly and not bg and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].bgOnly and JukedPartyDB[CharIndex].arenaOnly and not arena) or (not JukedPartyDB[CharIndex].arenaOnly and JukedPartyDB[CharIndex].bgOnly and not bg) then return end
		local cold_snap={82676,44572,45438}
		local prep={1766,1856,36554,51722}
		local readiness={19263,19503,34490}
		


		if spellID == 11958 then --cold snap 82676 Ring of Frost -- 44572 Deep Freeze -- 45438 Ice Block
			if JukedPartyDB[CharIndex].prio and isPrio(ability) then
				for _,abil in ipairs(cold_snap) do
					if activetimers[abil] then
						JukedParty_StopAbility(bar2[abil],abil)
					end
				end
			else
				for _,abil in ipairs(cold_snap) do
					if activetimers[abil] then
						JukedParty_StopAbility(bar[abil],abil)
					end
				end
			end
		elseif spellID == 14185 then --prep
			if JukedPartyDB[CharIndex].prio and isPrio(ability) then
				for _,abil in ipairs(prep) do
					if activetimers[abil] then
						JukedParty_StopAbility(bar2[abil],abil)
					end
				end
			else
				for _,abil in ipairs(prep) do
					if activetimers[abil] then
						JukedParty_StopAbility(bar[abil],abil)
					end
				end
			end
			--[[ 1766  Kick 1856  Vanish 36554 Shadowstep 76577 Smoke Bomb 51722 Dismantle
				Non tracked: Sprint, Smoke Bomb]]
		elseif spellID == 23989 then --readiness
			if JukedPartyDB[CharIndex].prio and isPrio(ability) then
				for _,abil in ipairs(readiness) do
					if activetimers[abil] then
						JukedParty_StopAbility(bar2[abil],abil)
					end
				end
			else
				for _,abil in ipairs(readiness) do
					if activetimers[abil] then
						JukedParty_StopAbility(bar[abil],abil)
					end
				end
			end
		end
		useSecondDuration = false

		if abilities[spellID] then	
			if useSecondDuration and spellID == 16979 then
				if JukedPartyDB[CharIndex].prio and isPrio(spellID) then
					bar2[spellID].duration=30
				else
					bar[spellID].duration=30
				end
			elseif spellID == 16979 then
				if JukedPartyDB[CharIndex].prio and isPrio(spellID) then
					bar2[spellID].duration=15
				else
					bar[spellID].duration=15
				end
			end
			--if JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio then
			--	JukedParty_AddIcon(spellID)
			--end
			if JukedPartyDB[CharIndex].prio and isPrio(spellID) then
				if JukedPartyDB[CharIndex].smartPrio then JukedParty_AddIcon(spellID) end
				JukedParty_StartTimer(bar2[spellID],spellID)
			else
				if JukedPartyDB[CharIndex].smart then JukedParty_AddIcon(spellID) end
				JukedParty_StartTimer(bar[spellID],spellID)
			end
		end
	end
end

JukedParty_COMBAT_LOG_EVENT_UNFILTERED = JukedParty_COMBAT_LOG_EVENT_UNFILTERED()


local function JukedParty_ResetAllTimers()
	for _,ability in ipairs(spell_table) do
		if JukedPartyDB[CharIndex].prio and isPrio(ability.spellID) then
			JukedParty_StopAbility(bar2[ability.spellID],ability.spellID)
		else
			JukedParty_StopAbility(bar[ability.spellID],ability.spellID)
		end
	end
	if not (JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio) and not ((JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio) and (JukedPartyDB[CharIndex].hidden or JukedPartyDB[CharIndex].hidden2)) then
		JukedParty_Repos()
	end

end

local function JukedParty_Reset()
	JukedPartyDB[CharIndex] = JukedPartyDB[CharIndex] or { scale = 1,scale2=1, hidden = false,hidden2=false, smart=false,smartPrio=false,prio = false, cols=6, colsPrio=6, arenaOnly=false, bgOnly=false, lock = false,lockPrio=false,growUp=1,growLeft=-1 ,noCD=false,prioOnly=false,lockPrio=false}
	JukedParty_ResetAllTimers()
	JukedParty_UpdateBar()
	JukedParty_LoadPosition()
end
local function JukedParty_PLAYER_ENTERING_WORLD(self)
	arena=isInArena()
	bg=isInBG()
	JukedParty_Reset()
end
local function JukedParty_Test()
	if (JukedPartyDB[CharIndex].smart or JukedPartyDB[CharIndex].smartPrio) and (JukedPartyDB[CharIndex].hidden or JukedPartyDB[CharIndex].hidden2) then 
		JukedParty_Repos()
	end
	if JukedPartyDB[CharIndex].prioOnly then 
		for _,ability in ipairs(spell_table) do
			if isPrio(ability.spellID) then
				if JukedPartyDB[CharIndex].smartPrio then JukedParty_AddIcon(ability.spellID) end
				if JukedPartyDB[CharIndex].prio then
					JukedParty_StartTimer(bar2[ability.spellID],ability.spellID)
				else
					JukedParty_StartTimer(bar[ability.spellID],ability.spellID)
				end
			end
		end
	else
		for _,ability in ipairs(spell_table) do
			if JukedPartyDB[CharIndex].prio and isPrio(ability.spellID) then
				if JukedPartyDB[CharIndex].smartPrio then JukedParty_AddIcon(ability.spellID) end
				JukedParty_StartTimer(bar2[ability.spellID],ability.spellID)
			else
			if JukedPartyDB[CharIndex].smart then JukedParty_AddIcon(ability.spellID) end
				JukedParty_StartTimer(bar[ability.spellID],ability.spellID)
			end
		end
	end
end


local cmdfuncs = {
	status = function() 
		ChatFrame1:AddMessage("Scale - Main Bar(1) = "..JukedPartyDB[CharIndex].scale.."  Prio Bar(2) = "..JukedPartyDB[CharIndex].scale2,0,1,1)
		local cd="Disabled"
		if (JukedPartyDB[CharIndex].hidden) then cd="Enabled"; end
		ChatFrame1:AddMessage("Hidden(1) - "..cd,0,1,1)
		cd="Disabled"
		if (JukedPartyDB[CharIndex].hidden2) then cd="Enabled"; end
		ChatFrame1:AddMessage("Hidden(2) - "..cd,0,1,1)
		cd="Disabled"
		if (JukedPartyDB[CharIndex].smart) then cd="Enabled"; end
		ChatFrame1:AddMessage("Smart(1) - "..cd,0,1,1)
		cd="Disabled"
		if (JukedPartyDB[CharIndex].smartPrio) then cd="Enabled"; end
		ChatFrame1:AddMessage("Smart(2) - "..cd,0,1,1)
		cd="unlocked"
		if (JukedPartyDB[CharIndex].lock) then cd="locked"; end
		ChatFrame1:AddMessage("Locked(1) - "..cd,0,1,1)
		cd="unlocked"
		if (JukedPartyDB[CharIndex].lockPrio) then cd="locked"; end
		ChatFrame1:AddMessage("Locked(2) - "..cd,0,1,1)
		cd="Disabled"
		if (JukedPartyDB[CharIndex].prio) then cd="Enabled"; end
		ChatFrame1:AddMessage("Prio - "..cd,0,1,1)
		cd="Disabled"
		if (JukedPartyDB[CharIndex].arenaOnly) then cd="Enabled"; end
		ChatFrame1:AddMessage("ArenaOnly - "..cd,0,1,1)
		cd="Disabled"
		if (JukedPartyDB[CharIndex].bgOnly) then cd="Enabled"; end
		ChatFrame1:AddMessage("BGOnly - "..cd,0,1,1)
		cd="growing down"
		if (JukedPartyDB[CharIndex].growUp==-1) then cd="growing up"; end
		ChatFrame1:AddMessage("Cooldowns are "..cd.." from the anchor",0,1,1)
		cd="Disabled"
		cd="growing right"
		if (JukedPartyDB[CharIndex].growLeft==-1) then cd="growing left"; end
		ChatFrame1:AddMessage("Cooldowns are "..cd.." from the anchor",0,1,1)
		cd="Disabled"
		if (not JukedPartyDB[CharIndex].noCD) then cd="Enabled"; end
		ChatFrame1:AddMessage("JukedParty cooldown display is "..cd,0,1,1)
		cd="all spell cooldowns"
		if (JukedPartyDB[CharIndex].prioOnly) then cd="ONLY priority cooldowns"; end
		ChatFrame1:AddMessage("Displaying "..cd.."(PrioOnly mode="..tostring(JukedPartyDB[CharIndex].prioOnly)..")",0,1,1)
		ChatFrame1:AddMessage("Columns per row:  Main Bar(1) = "..JukedPartyDB[CharIndex].cols.."  Prio Bar(2) = "..JukedPartyDB[CharIndex].colsPrio,0,1,1)
	end,
	scale = function(id,v,from) 
		if not id or not v then 
			ChatFrame1:AddMessage("USAGE: scale <bar ID> <number>",0,1,0)
			ChatFrame1:AddMessage("Bar IDs: Main bar = 1   Prio Bar = 2",0,1,0)
			ChatFrame1:AddMessage("Current settings: Main Bar(1) = "..JukedPartyDB[CharIndex].scale.."  Prio Bar(2) = "..JukedPartyDB[CharIndex].scale2,0,1,0)
			return
		end
		if ((id == 1 or id == 2) and v >= 0) then 
			if id==1 then
				JukedPartyDB[CharIndex].scale = v
			elseif id == 2 then
				JukedPartyDB[CharIndex].scale2=v
			end
			if not from then
				ChatFrame1:AddMessage("Scale for bar"..id.." set to"..v,0,1,0)
			end
			JukedParty_UpdateBar()
			return
		end
		if not from then
			ChatFrame1:AddMessage("USAGE: scale <bar ID> <number>",0,1,0)
			ChatFrame1:AddMessage("Bar IDs: Main bar = 1   Prio Bar = 2",0,1,0)
			ChatFrame1:AddMessage("Current settings: Main Bar(1) = "..JukedPartyDB[CharIndex].scale.."  Prio Bar(2) = "..JukedPartyDB[CharIndex].scale2,0,1,0)
		end
	end,
	hidden = function(id,from) 
		if not id then 
			ChatFrame1:AddMessage("USAGE: hidden <bar ID>",0,1,0)
			ChatFrame1:AddMessage("Bar IDs: Main bar = 1   Prio Bar = 2",0,1,0)
			return
		end
		if ((id == 1 or id == 2)) then 
			local cd="Disabled"
			if id == 1 then
				JukedPartyDB[CharIndex].hidden = not JukedPartyDB[CharIndex].hidden
				if (JukedPartyDB[CharIndex].hidden) then cd="Enabled"; end
			elseif id == 2 then
				JukedPartyDB[CharIndex].hidden2 = not JukedPartyDB[CharIndex].hidden2
				if (JukedPartyDB[CharIndex].hidden2) then cd="Enabled"; end
			end
			if not from then
				ChatFrame1:AddMessage("JukedParty hidden("..id..") mode is now "..cd,0,1,1)
				ChatFrame1:AddMessage("Enabled = Spells are hidden when not on cooldown",0,1,0)
				ChatFrame1:AddMessage("Disabled = Spells are always visible",0,1,0)
				ChatFrame1:AddMessage("Note: If Smart & Hidden mode are enabled, the cooldowns realign to the anchor when off cooldown",0,1,0)
			end
			JukedParty_UpdateBar() 
			JukedParty_Repos() 
		end
	end,
	smart = function(id,from) 
		if not id then 
			ChatFrame1:AddMessage("USAGE: smart <bar ID>",0,1,0)
			ChatFrame1:AddMessage("Bar IDs: Main bar = 1   Prio Bar = 2",0,1,0)
			return
		end
		local cd="Disabled"
		if ((id == 1 or id == 2)) then 
			if id == 1 then
				JukedPartyDB[CharIndex].smart = not JukedPartyDB[CharIndex].smart
				if (JukedPartyDB[CharIndex].smart) then cd="Enabled"; end
			elseif id == 2 then
				JukedPartyDB[CharIndex].smartPrio = not JukedPartyDB[CharIndex].smartPrio
				if (JukedPartyDB[CharIndex].smartPrio) then cd="Enabled"; end
			end
		end
		if not from then
			ChatFrame1:AddMessage("JukedParty smart mode is now "..cd,0,1,1)
			ChatFrame1:AddMessage("Enabled = Spells are only displayed once used and in the order they're used",0,1,0)
			ChatFrame1:AddMessage("Disabled = Spells are always displayed in the same order",0,1,0)
			ChatFrame1:AddMessage("Note: If Smart & Hidden mode are enabled, the cooldowns realign to the anchor when off cooldown",0,1,0)
		end
		JukedParty_Reset() 
	end,
	lock = function(id,from) 
		if not id then 
			ChatFrame1:AddMessage("USAGE: lock <bar ID>",0,1,0)
			ChatFrame1:AddMessage("Bar IDs: Main bar = 1   Prio Bar = 2",0,1,0)
			return
		end
		if ((id == 1 or id == 2)) then 
			local cd="unlocked"
			if id == 1 then
				JukedPartyDB[CharIndex].lock = not JukedPartyDB[CharIndex].lock
				if (JukedPartyDB[CharIndex].hidden) then cd="locked"; end
			elseif id == 2 then
				JukedPartyDB[CharIndex].lockPrio = not JukedPartyDB[CharIndex].lockPrio
				if (JukedPartyDB[CharIndex].lockPrio) then cd="locked"; end
			end
			if not from then ChatFrame1:AddMessage("JukedParty bar"..id.." is now "..cd,0,1,1) end
		end
		if not from then
			ChatFrame1:AddMessage("Locked = Bars can't be moved",0,1,0)
			ChatFrame1:AddMessage("Unlocked = Bars can be moved",0,1,0)
		end
		JukedParty_UpdateBar()
	end,
	prio = function(from) 
		JukedPartyDB[CharIndex].prio = not JukedPartyDB[CharIndex].prio
		if not from then
			local cd="Disabled"
			if (JukedPartyDB[CharIndex].prio) then cd="Enabled"; end
			ChatFrame1:AddMessage("JukedParty Prio bar is now "..cd,0,1,1)
			ChatFrame1:AddMessage("Enabled = A second bar is created, displaying priority spells",0,1,0)
			ChatFrame1:AddMessage("Disabled = JukedParty displays all spells on the main bar",0,1,0)
		end
		local temp1=JukedPartyDB[CharIndex].smart
		local temp2=JukedPartyDB[CharIndex].smartPrio

		JukedParty_UpdateBar()
		JukedPartyDB[CharIndex].smartPrio=false
		JukedPartyDB[CharIndex].smart=false
		JukedParty_Repos() 
		JukedPartyDB[CharIndex].smart=temp1
		JukedPartyDB[CharIndex].smartPrio=temp2
		JukedParty_UpdateBar()
	end,
	arenaonly = function(from) 
		JukedPartyDB[CharIndex].arenaOnly = not JukedPartyDB[CharIndex].arenaOnly
		if not from then 
			local cd="Disabled"
			if (JukedPartyDB[CharIndex].arenaOnly) then cd="Enabled"; end
			ChatFrame1:AddMessage("JukedParty Arena Only mode is now "..cd,0,1,1)
			ChatFrame1:AddMessage("Enabled = JukedParty is displayed ONLY in Arenas",0,1,0)
			ChatFrame1:AddMessage("Disabled = JukedParty is displayed outside of Arenas",0,1,0)
			ChatFrame1:AddMessage("Note: If BGOnly & ArenaOnly are enabled, it will work in Arenas and BGs",0,1,0)
		end
		JukedParty_Reset() 
	end,
	bgonly = function(from) 
		JukedPartyDB[CharIndex].bgOnly = not JukedPartyDB[CharIndex].bgOnly
		if not from then 
			local cd="Disabled"
			if (JukedPartyDB[CharIndex].bgOnly) then cd="Enabled"; end
			ChatFrame1:AddMessage("JukedParty BG Only mode is now "..cd,0,1,1)
			ChatFrame1:AddMessage("Enabled = JukedParty is displayed ONLY in Battlegrounds",0,1,0)
			ChatFrame1:AddMessage("Disabled = JukedParty is displayed outside of Battlegrounds",0,1,0)
			ChatFrame1:AddMessage("Note: If BGOnly & ArenaOnly are enabled, it will work in Arenas and BGs",0,1,0)
		end
		JukedParty_Reset() 
	end,
	growup=function(from) 		
		JukedPartyDB[CharIndex].growUp=JukedPartyDB[CharIndex].growUp*-1
		if not from then 
			local text="growing down"
			if (JukedPartyDB[CharIndex].growUp==-1) then text="growing up"; end
			ChatFrame1:AddMessage("JukedParty cooldowns are "..text.." from the anchor",0,1,1)
		end
		JukedParty_Repos()
		end,
	growleft=function(from) 		
		JukedPartyDB[CharIndex].growLeft=JukedPartyDB[CharIndex].growLeft*-1
		if not from then 
			local text="growing right"
			if (JukedPartyDB[CharIndex].growLeft==-1) then text="growing left"; end
			ChatFrame1:AddMessage("JukedParty cooldows are "..text.." from the anchor",0,1,1)
		end
		JukedParty_Repos()
		end,
	nocd=function(from) 
		JukedPartyDB[CharIndex].noCD = not JukedPartyDB[CharIndex].noCD
		if not from then 
			local cd="Disabled"
			if (not JukedPartyDB[CharIndex].noCD) then cd="Enabled"; end
			ChatFrame1:AddMessage("JukedParty cooldown display is now "..cd,0,1,1)
			ChatFrame1:AddMessage("Enabled = JukedParty displays text",0,1,0)
			ChatFrame1:AddMessage("Disabled = JukedParty displays no text, OmniCC can be used",0,1,0)
		end
		JukedParty_Reset()
	end,
	prioonly=function(from)
		JukedPartyDB[CharIndex].prioOnly=not JukedPartyDB[CharIndex].prioOnly
		if not from then
			local cd="all spell cooldowns"
			if (JukedPartyDB[CharIndex].prioOnly) then cd="ONLY priority cooldowns"; end
			ChatFrame1:AddMessage("JukedParty is now displaying "..cd,0,1,1)
		end
		JukedParty_Reset()  
	end,
	opts=function()
		InterfaceOptionsFrame_OpenToCategory(JukedParty.mainpanel);
	end,
	gui=function()
		InterfaceOptionsFrame_OpenToCategory(JukedParty.mainpanel);
	end,
	config=function()
		InterfaceOptionsFrame_OpenToCategory(JukedParty.mainpanel);
	end,
	cols = function(id,v,from) 
		if not id or not v then 
			ChatFrame1:AddMessage("USAGE: cols <bar ID> <number>",0,1,0)
			ChatFrame1:AddMessage("Bar IDs: Main bar = 1   Prio Bar = 2",0,1,0)
			ChatFrame1:AddMessage("Current settings: Main Bar(1) = "..JukedPartyDB[CharIndex].cols.."  Prio Bar(2) = "..JukedPartyDB[CharIndex].colsPrio,0,1,0)
			return
		end
		if ((id == 1 or id == 2) and v >= 0) then 
			if id==1 then
				if (v==0) then
					JukedPartyDB[CharIndex].cols = getTotalMain()
				else
					JukedPartyDB[CharIndex].cols = v
				end
			elseif id==2 then
				if (v==0) then
					JukedPartyDB[CharIndex].colsPrio = getTotalPrio()
				else
					JukedPartyDB[CharIndex].colsPrio = v
				end
			end
			if not from then
				ChatFrame1:AddMessage("Cols for bar"..id.." set to "..v,0,1,0)
			end
			JukedParty_Repos()
			return	
		end
		if not from then
			ChatFrame1:AddMessage("USAGE: /JukedParty cols <bar ID> <number>",0,1,0)
			ChatFrame1:AddMessage("Bar IDs: Main bar = 1   Prio Bar = 2",0,1,0)
			ChatFrame1:AddMessage("Current settings: Main Bar(1) = "..JukedPartyDB[CharIndex].cols.."  Prio Bar(2) = "..JukedPartyDB[CharIndex].colsPrio,0,1,0)
			ChatFrame1:AddMessage("Example: set main bar cols to 6: /JukedParty cols 1 6",0,1,0)
		end
	end,
	reset = function() JukedParty_Reset() end,
	test = function() JukedParty_Test() end,
}

local cmdtbl = {}
function JukedParty_Command(cmd)
	for k in ipairs(cmdtbl) do
		cmdtbl[k] = nil
	end
	for v in gmatch(cmd, "[%d|%a|.]+") do
		tinsert(cmdtbl, v)
	end
  local cb = cmdfuncs[cmdtbl[1]] 
  if cb then
  	local s = tonumber(cmdtbl[2])
  	local ss = tonumber(cmdtbl[3])
  	cb(s,ss)
  else
	ChatFrame1:AddMessage("JukedParty Help",0,1,0)
	ChatFrame1:AddMessage("config - Display current value of options",0,1,0)
	ChatFrame1:AddMessage("scale <bar ID> <number> - Sets the scale factor for the given bar",0,1,0)
  	ChatFrame1:AddMessage("hidden <bar ID> (toggle) - Hides spell icons when off cooldown",0,1,0)
	ChatFrame1:AddMessage("smart <bar ID>(toggle) - Only show CD when used",0,1,0)
  	ChatFrame1:AddMessage("lock <bar ID>(toggle) - Locks the bars in place",0,1,0)
	ChatFrame1:AddMessage("growup (toggle) - The icons grow upwards from the anchor if enabled",0,1,0)
	ChatFrame1:AddMessage("growleft (toggle) - The icons grow left from the anchor if enabled",0,1,0)
	ChatFrame1:AddMessage("prio (toggle) - Displays second anchor with priority spells",0,1,0)
	ChatFrame1:AddMessage("arenaonly (toggle) - Only display cooldowns if in an arena",0,1,0)
	ChatFrame1:AddMessage("bgonly (toggle) - Only display cooldowns if in a battleground",0,1,0)
	ChatFrame1:AddMessage("prioonly (toggle) - Only displays priority cooldowns",0,1,0)
	ChatFrame1:AddMessage("nocd (toggle) - Disables the JukedParty cooldown text and allows omniCC",0,1,0)
	ChatFrame1:AddMessage("cols <bar ID> <num> (0 = 1 row) - Set number of spells per row for the given bar",0,1,0)
  	ChatFrame1:AddMessage("test - Activates all cooldowns to test JukedParty",0,1,0)
  	ChatFrame1:AddMessage("reset - Resets all cooldowns",0,1,0)
  end
end

local function JukedParty_OnLoad(self)
	self:RegisterEvent("PLAYER_ENTERING_WORLD")
	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
	if not JukedPartyDB then
		JukedPartyDB={}
	end
	JukedPartyDB["Default"]= JukedPartyDB["Default"] or { scale = 1,scale2=1 , hidden = false,hidden2=false, smart=false, smartPrio=false,prio = false, cols=6, colsPrio=6, arenaOnly=false, bgOnly=false, lock = false,growUp=1,growLeft=1, noCD=false,prioOnly=false,}
	JukedPartyDB["CharsUse"]=JukedPartyDB["CharsUse"] or {}
	
	if (JukedPartyDB["CharsUse"][CharIndex]) then
		if (JukedPartyDB[JukedPartyDB["CharsUse"][CharIndex]]) then
			CharIndex=JukedPartyDB["CharsUse"][CharIndex]
		else
			JukedPartyDB["CharsUse"][CharIndex]=CharIndex
			if not JukedPartyDB[CharIndex] then
				JukedPartyDB[CharIndex]=JukedPartyDB["Default"]
			end
		end	
	else
		JukedPartyDB["CharsUse"][CharIndex]=CharIndex
		if not JukedPartyDB[CharIndex] then
			JukedPartyDB[CharIndex]=JukedPartyDB["Default"]
		end
	end
	for k,v in pairs(JukedPartyDB) do
		if not (type(JukedPartyDB[k]) == "table" ) then 
			JukedPartyDB[k]=nil
		elseif (k=="Position" and (JukedPartyDB["Position"]["scale2"]==nil)) then 
			JukedPartyDB[k]=nil
		end
	end
	
	--[[if not JukedPartyDB[CharIndex].scale then JukedPartyDB[CharIndex].scale = 1 end
	if not JukedPartyDB[CharIndex].scale2 then JukedPartyDB[CharIndex].scale2 = 1 end
	if not JukedPartyDB[CharIndex].hidden then JukedPartyDB[CharIndex].hidden = false end
	if not JukedPartyDB[CharIndex].hidden2 then JukedPartyDB[CharIndex].hidden2 = false end
	if not JukedPartyDB[CharIndex].smart then JukedPartyDB[CharIndex].smart = false end
	if not JukedPartyDB[CharIndex].smartPrio then JukedPartyDB[CharIndex].smartPrio = false end
	if not JukedPartyDB[CharIndex].prio then JukedPartyDB[CharIndex].prio = false end
	if not JukedPartyDB[CharIndex].growUp then JukedPartyDB[CharIndex].growUp=1 end
	if not JukedPartyDB[CharIndex].growLeft then JukedPartyDB[CharIndex].growLeft=1 end
	if not JukedPartyDB[CharIndex].arenaOnly then JukedPartyDB[CharIndex].arenaOnly=false end
	if not JukedPartyDB[CharIndex].bgOnly then JukedPartyDB[CharIndex].bgOnly=false end
	if not JukedPartyDB[CharIndex].noCD then JukedPartyDB[CharIndex].noCD=false end
	if not JukedPartyDB[CharIndex].cols then JukedPartyDB[CharIndex].cols = 6 end
	if not JukedPartyDB[CharIndex].colsPrio then JukedPartyDB[CharIndex].colsPrio = 6 end
	if not JukedPartyDB[CharIndex].prioOnly then JukedPartyDB[CharIndex].prioOnly=false end
	if not JukedPartyDB[CharIndex].lock then JukedPartyDB[CharIndex].lock = false end
	if not JukedPartyDB[CharIndex].lockPrio then JukedPartyDB[CharIndex].lockPrio = false end]]
	JukedParty_CreateBar()
	
	SlashCmdList["JukedParty"] = JukedParty_Command
	SLASH_JukedParty1 = "/JukedParty"
	SLASH_JukedParty2 = "/jd"
	SLASH_JukedParty3 = "/ib"
	ChatFrame1:AddMessage("JukedParty by Robrman, inspired by Kollektiv's InterruptBar. Type /JukedParty or /jd for options.",0,1,0)
end

local eventhandler = {
	["VARIABLES_LOADED"] = function(self) JukedParty_OnLoad(self) end,
	["PLAYER_ENTERING_WORLD"] = function(self) JukedParty_PLAYER_ENTERING_WORLD(self) end,
	["COMBAT_LOG_EVENT_UNFILTERED"] = function(self,...) JukedParty_COMBAT_LOG_EVENT_UNFILTERED(...) end,
}

local function JukedParty_OnEvent(self,event,...)
	eventhandler[event](self,...)
end

frame = CreateFrame("Frame","JukedPartyMainFrame",UIParent)
frame:SetScript("OnEvent",JukedParty_OnEvent)
frame:RegisterEvent("VARIABLES_LOADED")

JukedParty = {};
JukedParty.mainpanel = CreateFrame( "Frame", "JukedPartyMainPanel", UIParent );
JukedParty.mainpanel.name = "JukedParty";
local title = JukedParty.mainpanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 20, -10)
title:SetText("JukedParty")
local subtitle = JukedParty.mainpanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
subtitle:SetPoint("RIGHT", JukedParty.mainpanel, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("General options for JukedParty")

local buttonPositionY = -60;
local buttonPositionX = 20;

local t = {"prio","prioOnly","arenaOnly","bgOnly","nocd","growLeft","growUp"};
local general_cmd_table={cmdfuncs["prio"],cmdfuncs["prioonly"],cmdfuncs["arenaonly"],cmdfuncs["bgonly"],cmdfuncs["nocd"],cmdfuncs["growleft"],cmdfuncs["growup"]};
local t2 = {"Show Priority bar","Priority Bar Only", "Display Only in Arenas","Display Only in Battlegrounds","Hide JukedParty cooldown time","Grow icons left from the anchor","Grow icons up from the anchor"};
for i,v in ipairs (t) do
	local JukedParty_IconOptions_CheckButton = CreateFrame("CheckButton", "JukedParty_Button_"..v, JukedParty.mainpanel, "OptionsCheckButtonTemplate");
	JukedParty_IconOptions_CheckButton:SetPoint("TOPLEFT",buttonPositionX,buttonPositionY);
	getglobal(JukedParty_IconOptions_CheckButton:GetName().."Text"):SetText(t2[i]);

	local function JukedParty_IconOptions_CheckButton_OnClick()
			general_cmd_table[i](1,"gui")
	end

	local function JukedParty_IconOptions_CheckButton_OnShow()
		if (v == "growLeft" or v == "growUp") then
			JukedParty_IconOptions_CheckButton:SetChecked(JukedPartyDB[CharIndex][v]==-1);
		else
			JukedParty_IconOptions_CheckButton:SetChecked(JukedPartyDB[CharIndex][v]);
		end
	end

	JukedParty_IconOptions_CheckButton:RegisterForClicks("AnyUp");
	JukedParty_IconOptions_CheckButton:SetScript("OnClick", JukedParty_IconOptions_CheckButton_OnClick);
	JukedParty_IconOptions_CheckButton:SetScript("OnShow", JukedParty_IconOptions_CheckButton_OnShow);
	buttonPositionY = buttonPositionY - 30;
end

-- Add the panel to the Interface Options
InterfaceOptions_AddCategory(JukedParty.mainpanel);
-- Make a child panel
JukedParty.mainbarpanel = CreateFrame( "Frame", "MainBarPanel", JukedParty.mainpanel);
JukedParty.mainbarpanel.name = "Main Bar";
-- Specify childness of this panel (this puts it under the little red [+], instead of giving it a normal AddOn category)
JukedParty.mainbarpanel.parent = JukedParty.mainpanel.name;
			
local title = JukedParty.mainbarpanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 20, -10)
title:SetText("Main Bar Options")

local subtitle = JukedParty.mainbarpanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
subtitle:SetPoint("RIGHT", JukedParty.mainbarpanel, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("Options for JukedParty Main Bar")	

buttonPositionY = -60;
buttonPositionX = 20;

-- Main bar options
local t = {"hidden","smart","lock"};
local bar_cmd_table={cmdfuncs["hidden"],cmdfuncs["smart"],cmdfuncs["lock"]};
local t2 = {"Hide Icons","Smart", "Lock frame"};
for i,v in ipairs (t) do
	local JukedParty_IconOptions_CheckButton = CreateFrame("CheckButton", "JukedParty_Button_"..v, JukedParty.mainbarpanel, "OptionsCheckButtonTemplate");
	JukedParty_IconOptions_CheckButton:SetPoint("TOPLEFT",buttonPositionX,buttonPositionY);
	getglobal(JukedParty_IconOptions_CheckButton:GetName().."Text"):SetText(t2[i]);

	local function JukedParty_IconOptions_CheckButton_OnClick()
			bar_cmd_table[i](1,"gui")
	end

	local function JukedParty_IconOptions_CheckButton_OnShow()
		JukedParty_IconOptions_CheckButton:SetChecked(JukedPartyDB[CharIndex][v]);
	end

	JukedParty_IconOptions_CheckButton:RegisterForClicks("AnyUp");
	JukedParty_IconOptions_CheckButton:SetScript("OnClick", JukedParty_IconOptions_CheckButton_OnClick);
	JukedParty_IconOptions_CheckButton:SetScript("OnShow", JukedParty_IconOptions_CheckButton_OnShow);
	buttonPositionY = buttonPositionY - 30;
end
local tsliders = {"cols","scale"};
local slider_table={cmdfuncs["cols"],cmdfuncs["scale"]};
local slidert2 = {"Number of cols","Scale (default 1.0)" };
buttonPositionY = buttonPositionY - 30;
for i,v in ipairs (tsliders) do
	local JukedParty_IconOptions_Slider = CreateFrame("Slider", "JukedParty_Slider_"..v, JukedParty.mainbarpanel, "OptionsSliderTemplate");
	JukedParty_IconOptions_Slider:SetPoint("TOPLEFT",buttonPositionX,buttonPositionY);
	getglobal(JukedParty_IconOptions_Slider:GetName() .. 'Low'):SetText('-');
	getglobal(JukedParty_IconOptions_Slider:GetName() .. 'High'):SetText('+');
	getglobal(JukedParty_IconOptions_Slider:GetName() .. 'Text'):SetText(slidert2[i].."\nValue: "..JukedPartyDB[CharIndex][v]);

	if (v == "cols") then
		JukedParty_IconOptions_Slider:SetMinMaxValues(0,#(spell_table));
		JukedParty_IconOptions_Slider:SetValueStep(1.0);
	elseif (v == "scale") then
		JukedParty_IconOptions_Slider:SetMinMaxValues(0.1,2.0);
		JukedParty_IconOptions_Slider:SetValueStep(0.1);
	end
	
	local function JukedParty_IconOptions_Slider_OnShow()
		JukedParty_IconOptions_Slider:SetValue(JukedPartyDB[CharIndex][v]);
	end

	local function JukedParty_IconOptions_Slider_OnValueChanged()
		slider_table[i](1,JukedParty_IconOptions_Slider:GetValue(),"gui");
		getglobal(JukedParty_IconOptions_Slider:GetName() .. 'Text'):SetText(slidert2[i].."\nValue: "..JukedPartyDB[CharIndex][v]);
	end

	JukedParty_IconOptions_Slider:SetScript("OnValueChanged", JukedParty_IconOptions_Slider_OnValueChanged);
	JukedParty_IconOptions_Slider:SetScript("OnShow", JukedParty_IconOptions_Slider_OnShow);
	buttonPositionY = buttonPositionY - 60;
end

InterfaceOptions_AddCategory(JukedParty.mainbarpanel);
-- Make a child panel
JukedParty.priobarpanel = CreateFrame( "Frame", "PrioBarPanel", JukedParty.mainpanel);
JukedParty.priobarpanel.name = "Prio Bar";
-- Specify childness of this panel (this puts it under the little red [+], instead of giving it a normal AddOn category)
JukedParty.priobarpanel.parent = JukedParty.mainpanel.name;

local title = JukedParty.priobarpanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 20, -10)
title:SetText("Prio Bar Options")

local subtitle = JukedParty.priobarpanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
subtitle:SetPoint("RIGHT", JukedParty.priobarpanel, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("Options for JukedParty Prio Bar")	

buttonPositionY = -60;
buttonPositionX = 20;
local priot = {"hidden2","smartPrio","lockPrio"};
for i,v in ipairs (priot) do
	local JukedParty_IconOptions_CheckButton = CreateFrame("CheckButton", "JukedParty_Button_"..v, JukedParty.priobarpanel, "OptionsCheckButtonTemplate");
	JukedParty_IconOptions_CheckButton:SetPoint("TOPLEFT",buttonPositionX,buttonPositionY);
	getglobal(JukedParty_IconOptions_CheckButton:GetName().."Text"):SetText(t2[i]);

	local function JukedParty_IconOptions_CheckButton_OnClick()
			bar_cmd_table[i](2,"gui")
	end

	local function JukedParty_IconOptions_CheckButton_OnShow()
		JukedParty_IconOptions_CheckButton:SetChecked(JukedPartyDB[CharIndex][v]);
	end

	JukedParty_IconOptions_CheckButton:RegisterForClicks("AnyUp");
	JukedParty_IconOptions_CheckButton:SetScript("OnClick", JukedParty_IconOptions_CheckButton_OnClick);
	JukedParty_IconOptions_CheckButton:SetScript("OnShow", JukedParty_IconOptions_CheckButton_OnShow);

	buttonPositionY = buttonPositionY - 30;
end
tsliders = {"colsPrio","scale2"};
buttonPositionY = buttonPositionY - 30;
for i,v in ipairs (tsliders) do
	local JukedParty_IconOptions_Slider = CreateFrame("Slider", "JukedParty_Slider_"..v, JukedParty.priobarpanel, "OptionsSliderTemplate");
	JukedParty_IconOptions_Slider:SetPoint("TOPLEFT",buttonPositionX,buttonPositionY);

	getglobal(JukedParty_IconOptions_Slider:GetName() .. 'Low'):SetText('-');
	getglobal(JukedParty_IconOptions_Slider:GetName() .. 'High'):SetText('+');
	getglobal(JukedParty_IconOptions_Slider:GetName() .. 'Text'):SetText(slidert2[i].."\nValue: "..JukedPartyDB[CharIndex][v]);
	
	if (v == "colsPrio") then
		local val = getTotalPrio("gui");
		JukedParty_IconOptions_Slider:SetMinMaxValues(0,val+1);
		JukedParty_IconOptions_Slider:SetValueStep(1.0);
	elseif (v == "scale2") then
		
		JukedParty_IconOptions_Slider:SetMinMaxValues(0.1,2.0);
		JukedParty_IconOptions_Slider:SetValueStep(0.1);
	end
	
	local function JukedParty_IconOptions_Slider_OnShow()
		JukedParty_IconOptions_Slider:SetValue(JukedPartyDB[CharIndex][v]);
	end

	local function JukedParty_IconOptions_Slider_OnValueChanged()
		slider_table[i](2,JukedParty_IconOptions_Slider:GetValue(),"gui");
		getglobal(JukedParty_IconOptions_Slider:GetName() .. 'Text'):SetText(slidert2[i].."\nValue: "..JukedPartyDB[CharIndex][v]);
	end

	JukedParty_IconOptions_Slider:SetScript("OnValueChanged", JukedParty_IconOptions_Slider_OnValueChanged);
	JukedParty_IconOptions_Slider:SetScript("OnShow", JukedParty_IconOptions_Slider_OnShow);

	buttonPositionY = buttonPositionY - 60;
end
InterfaceOptions_AddCategory(JukedParty.priobarpanel);


-- Make a child panel
JukedParty.profilepanel = CreateFrame( "Frame", "ProfilePanel", JukedParty.mainpanel);
JukedParty.profilepanel.name = "Profiles";
-- Specify childness of this panel (this puts it under the little red [+], instead of giving it a normal AddOn category)
JukedParty.profilepanel.parent = JukedParty.mainpanel.name;

local title = JukedParty.profilepanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 20, -10)
title:SetText("Prio Bar Options")

local subtitle = JukedParty.profilepanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
subtitle:SetPoint("RIGHT", JukedParty.profilepanel, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("JukedParty Profile Options")	

buttonPositionY = -60;
buttonPositionX = 20;
local UsingProfileLabel = JukedParty.profilepanel:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
UsingProfileLabel:SetHeight(32)
UsingProfileLabel:SetPoint("TOPLEFT", buttonPositionX,buttonPositionY)
UsingProfileLabel:SetNonSpaceWrap(true)
UsingProfileLabel:SetJustifyH("LEFT")
UsingProfileLabel:SetJustifyV("TOP")
UsingProfileLabel:SetText("Currently using: "..CharIndex)	


buttonPositionY=-100
local JukedParty_Options_EditBox = CreateFrame("EditBox", "JukedParty_NewProfile_NewID", JukedParty.profilepanel, "InputBoxTemplate");
JukedParty_Options_EditBox:SetPoint("TOPLEFT", buttonPositionX+5,buttonPositionY);
JukedParty_Options_EditBox:SetWidth(125);
JukedParty_Options_EditBox:SetHeight(32);
JukedParty_Options_EditBox:EnableMouse(true);
JukedParty_Options_EditBox:SetAutoFocus(false);
JukedParty_Options_EditBox_Text = JukedParty_Options_EditBox:CreateFontString(nil, 'ARTWORK', 'GameFontHighlightSmall');
JukedParty_Options_EditBox_Text:SetPoint("TOPLEFT", -3, 10);
JukedParty_Options_EditBox_Text:SetText("New Profile Name");


-- New Profile Save Button
local JukedParty_CreateProfile_SaveButton = CreateFrame("Button", "JukedParty_ProfileSaveButton",JukedParty.profilepanel, "OptionsButtonTemplate");
JukedParty_CreateProfile_SaveButton:SetPoint("TOPLEFT",buttonPositionX+130,buttonPositionY-5);
JukedParty_CreateProfile_SaveButton:SetWidth(50);
JukedParty_CreateProfile_SaveButton:SetHeight(21);
JukedParty_CreateProfile_SaveButton:SetText("Save");

local function CreateNewProfile()
	JukedPartyDB[JukedParty_Options_EditBox:GetText()]=JukedPartyDB[JukedParty_Options_EditBox:GetText()] or { scale = 1,scale2=1 , hidden = false,hidden2=false, smart=false, smartPrio=false,prio = false, cols=6, colsPrio=6, arenaOnly=false, bgOnly=false, lock = false,growUp=1,growLeft=1, noCD=false,prioOnly=false,}
	JukedParty_Options_EditBox:SetText("")
end
JukedParty_CreateProfile_SaveButton:SetScript("OnClick", CreateNewProfile)


buttonPositionX = buttonPositionX+195
buttonPositionY = -100
local subtitle = JukedParty.profilepanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", buttonPositionX+10,buttonPositionY+15)
--subtitle:SetPoint("RIGHT", JukedParty.mainpanel, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("Use Profile...")
if not DropDownMenuUse then
   CreateFrame("Button", "DropDownMenuUse", JukedParty.profilepanel, "UIDropDownMenuTemplate")
end
 
DropDownMenuUse:ClearAllPoints()
DropDownMenuUse:SetPoint("TOPLEFT", buttonPositionX-10, buttonPositionY)
DropDownMenuUse:Show()
 
local items = {}

local function OnClick(self)
   UIDropDownMenu_SetSelectedID(DropDownMenuUse, self:GetID())
   JukedPartyDB["CharsUse"][JukedPartyChar.." - "..JukedPartyRealm]=self:GetText()
   CharIndex=self:GetText()
   UsingProfileLabel:SetText("Currently using: "..CharIndex)
   JukedParty_Reset()
end
 
local function initialize(self, level)
items = {};
 	for k,v in pairs(JukedPartyDB) do
		if (type(JukedPartyDB[k]) == "table" and not(k =="CharsUse")) then table.insert(items,k) end
	end
   local info = UIDropDownMenu_CreateInfo()
   for k,v in pairs(items) do
      info = UIDropDownMenu_CreateInfo()
      info.text = v
      info.value = v
      info.func = OnClick
      UIDropDownMenu_AddButton(info, level)
   end
end

UIDropDownMenu_Initialize(DropDownMenuUse, initialize)
UIDropDownMenu_SetWidth(DropDownMenuUse, 160);
UIDropDownMenu_SetButtonWidth(DropDownMenuUse, 180)
UIDropDownMenu_SetSelectedID(DropDownMenuUse, 1)
UIDropDownMenu_JustifyText(DropDownMenuUse, "LEFT")

buttonPositionX = 5
buttonPositionY = buttonPositionY -60

local subtitle = JukedParty.profilepanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", buttonPositionX+20,buttonPositionY+15)
--subtitle:SetPoint("RIGHT", JukedParty.mainpanel, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("Copy From...")

if not DropDownMenuCopy then
   CreateFrame("Button", "DropDownMenuCopy", JukedParty.profilepanel, "UIDropDownMenuTemplate")
end

DropDownMenuCopy:ClearAllPoints()
DropDownMenuCopy:SetPoint("TOPLEFT", buttonPositionX, buttonPositionY)
DropDownMenuCopy:Show()
 
local function OnClick(self)
   UIDropDownMenu_SetSelectedID(DropDownMenuCopy, self:GetID())
   JukedPartyDB[JukedPartyChar.." - "..JukedPartyRealm]=JukedPartyDB[self:GetText()]
   CharIndex=JukedPartyChar.." - "..JukedPartyRealm
   UsingProfileLabel:SetText("Currently using: "..CharIndex)
   JukedParty_Reset()
end
 
local function initialize(self, level)
items = {};
 	for k,v in pairs(JukedPartyDB) do
		if (type(JukedPartyDB[k]) == "table" and not(k =="CharsUse")) then table.insert(items,k) end
	end
   local info = UIDropDownMenu_CreateInfo()
   for k,v in pairs(items) do
      info = UIDropDownMenu_CreateInfo()
      info.text = v
      info.value = v
      info.func = OnClick
      UIDropDownMenu_AddButton(info, level)
   end
end
 
UIDropDownMenu_Initialize(DropDownMenuCopy, initialize)
UIDropDownMenu_SetWidth(DropDownMenuCopy, 160);
UIDropDownMenu_SetButtonWidth(DropDownMenuCopy, 180)
UIDropDownMenu_SetSelectedID(DropDownMenuCopy, 1)
UIDropDownMenu_JustifyText(DropDownMenuCopy, "LEFT")

buttonPositionX = buttonPositionX+220

local subtitle = JukedParty.profilepanel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
subtitle:SetHeight(32)
subtitle:SetPoint("TOPLEFT", buttonPositionX,buttonPositionY+15)
--subtitle:SetPoint("RIGHT", JukedParty.mainpanel, -32, 0)
subtitle:SetNonSpaceWrap(true)
subtitle:SetJustifyH("LEFT")
subtitle:SetJustifyV("TOP")
subtitle:SetText("Delete Profile")

if not DropDownMenuDel then
   CreateFrame("Button", "DropDownMenuDel", JukedParty.profilepanel, "UIDropDownMenuTemplate")
end

DropDownMenuDel:ClearAllPoints()
DropDownMenuDel:SetPoint("TOPLEFT", buttonPositionX-20, buttonPositionY)
DropDownMenuDel:Show()
 
local function OnClick(self)
	JukedPartyDB[self:GetText()]=nil
	if (CharIndex == self:GetText()) then
		if ((JukedPartyChar.." - "..JukedPartyRealm)==self:GetText()) then
			JukedPartyDB["CharsUse"][JukedPartyChar.." - "..JukedPartyRealm]="Default"
			CharIndex="Default"
		else
			CharIndex=JukedPartyChar.." - "..JukedPartyRealm
			if not JukedPartyDB[CharIndex] then
				JukedPartyDB[CharIndex] = JukedPartyDB["Default"]
			end
			JukedPartyDB["CharsUse"][CharIndex]=CharIndex
		end
		UsingProfileLabel:SetText("Currently using: "..CharIndex)	
	end
	items = {};
 	for k,v in pairs(JukedPartyDB) do
		if (type(JukedPartyDB[k]) == "table" and not(k =="CharsUse")and not (k == "Default")) then table.insert(items,k) end
	end
	JukedParty_Reset()
end
 
local function initialize(self, level)
items = {};
 	for k,v in pairs(JukedPartyDB) do
		if (type(JukedPartyDB[k]) == "table" and not(k =="CharsUse")and not (k == "Default")) then table.insert(items,k) end
	end
	local info = UIDropDownMenu_CreateInfo()
	for k,v in pairs(items) do
		info = UIDropDownMenu_CreateInfo()
		info.text = v
		info.value = v
		info.func = OnClick
		UIDropDownMenu_AddButton(info, level)
	end
end
	
UIDropDownMenu_Initialize(DropDownMenuDel, initialize)
UIDropDownMenu_SetWidth(DropDownMenuDel, 160);
UIDropDownMenu_SetButtonWidth(DropDownMenuDel, 180)
UIDropDownMenu_SetSelectedID(DropDownMenuDel, 1)
UIDropDownMenu_JustifyText(DropDownMenuDel, "LEFT")
-- Add the child to the Interface Options
InterfaceOptions_AddCategory(JukedParty.profilepanel);

Last edited by MadMilitia : 07-24-13 at 11:55 AM. Reason: Rephrasing problem.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » JukedParty - Personal modifications - Help Request


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