﻿TMM = LibStub("AceAddon-3.0"):NewAddon("TMM", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0");
local TMM = TMM;
local config = LibStub("AceConfig-3.0")
local dialog = LibStub("AceConfigDialog-3.0")
local TMButtonTxt = {{},{},{},{},{},{},{},{},{},{}}
local TMisdButtons = {};
local TMisdMenu = {};
local class_colors = { ["HUNTER"] = "ABD473",["WARLOCK"] = "9482C9",["PRIEST"] = "FFFFFF",["PALADIN"] = "F58CBA",["MAGE"] = "69CCF0",["ROGUE"] = "FFF569",["DRUID"] = "FF7D0A",["SHAMAN"] = "0070DE",["WARRIOR"] = "C79C6E",["DEATHKNIGHT"] = "C41F3B" }
local defaults = {
  profile = {
	numMacros ={1,1,1,1,1,1,1,1,1,1},
	macroid = {
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
		{"","","","","","","","","","",""},
	},
	announce = {false,false,false,false,false,false,false,false,false,false},
	announceTo = {"PARTY","PARTY","PARTY","PARTY","PARTY","PARTY","PARTY","PARTY","PARTY","PARTY","PARTY"},
	ora = {false,false,false,false,false,false,false,false,false,false},
	lfg = {false,false,false,false,false,false,false,false,false,false},
	lfgh = {false,false,false,false,false,false,false,false,false,false},
	custom = {false,false,false,false,false,false,false,false,false,false},
	btank = {false,false,false,false,false,false,false,false,false,false},
	macroicon ={
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1},
		{1,1,1,1,1,1,1,1,1,1}
	},
	skills = {"","","","","","","","","",""},
	inuse = {false,false,false,false,false,false,false,false,false,false}
  }
}

function TMM:OnInitialize()
	self.db = LibStub("AceDB-3.0"):New("TMMDB", defaults)
	TMM:SecureHook(GameTooltip, "SetAction", self.TmmSetTooltip)
end

--Tooltips
function TMM:TmmSetTooltip(arg1)
	mname = GetActionText(arg1)
	if(mname)then
		str1,str2,str3 = strsplit("-", mname)
		if(str1 and str2 and str3)then
			for i=1,10 do
				if ( str2 == TMM.db.profile.skills[i] )then
					_,class = UnitClass(str1);
					if (class==nil) then class = "PRIEST" end
					GameTooltip:AddLine(format("target = |cFF%s%s|r",class_colors[class],str1),1,1,1)
					GameTooltip:Show()
				end
			end
		end
	end
end

--function to alter macros
function TMM:Alter_Macro(name,spec,nr)
	if InCombatLockdown()==nil then
		local icon
		if ( self.db.profile.custom[spec] ) then
			icon = self.db.profile.macroicon[spec][nr]
		else
			icon = 1
		end
		EditMacro(self.db.profile.macroid[spec][nr], format("%s-%s-%i", name, self.db.profile.skills[spec], nr), GetSpellorMacroIconInfo(icon), format("#showtooltip\n/use [@%s] %s", name, self.db.profile.skills[spec]),1)
		self.db.profile.macroid[spec][nr]=format("%s-%s-%i", name, self.db.profile.skills[spec], nr)
		TMButtonTxt[spec][nr] = self.db.profile.macroid[spec][nr]
		local buttoncnt = 1
		for j=1,10 do
			if (self.db.profile.inuse[j]) then
				for i=1,self.db.profile.numMacros[j] do
					local temp = format("%i-%i", j,i)
					TMisdButtons[temp] = {text=TMButtonTxt[j][i], dist=0, color="|cffffffff", tooltipText=""};
					TMisdMenu[buttoncnt] = temp;
					buttoncnt = buttoncnt + 1
				end
			end
		end
		TMisdMenu[buttoncnt] = nil
		local _,class = UnitClass(name);
		if (class==nil) then class = "PRIEST" end
		DEFAULT_CHAT_FRAME:AddMessage(format("|cff33ff99TMM|r: %s Macro %i target = |cFF%s%s|r", self.db.profile.skills[spec], nr, class_colors[class], name))
	end
end

--alter macro on entering rnd dungeon
 function TMM:PLAYER_ROLES_ASSIGNED()
	_,instanceType = IsInInstance()
	if (GetNumPartyMembers()==0 or instanceType~="party") then return; end
	local failed = true
	for j=1, 10 do
		if (self.db.profile.lfg[j]) then
			for i=1, 4 do
				if ((UnitGroupRolesAssigned("Party"..i)=="TANK") and not(un==UnitName("Party"..i))) then
					if (self.db.profile.inuse[j]) then
						TMM:Alter_Macro(UnitName(format("Party"..i)), j, 1)
						failed=false
					end
				end
			end
		elseif (self.db.profile.lfgh[j]) then
			for i=1, 4 do
				if ((UnitGroupRolesAssigned("Party"..i)=="HEALER") and not(un==UnitName("Party"..i))) then
					if (self.db.profile.inuse[j]) then
						TMM:Alter_Macro(UnitName(format("Party"..i)), j, 1)
						failed=false
					end
				end
			end
		end
	end

	if ( failed==true ) then
		TMM:CancelAllTimers()
		TMM:ScheduleTimer("PLAYER_ROLES_ASSIGNED", 2)
		return;
	end
end

--alter macro on ora2 mt change
function TMM:CHAT_MSG_ADDON(event,pre,msg,dist,snd)
	for j=1, 10 do
		if ( self.db.profile.ora[j] ) then
			if ( pre=="oRA" or pre=="CTRA" )then
				local str1,str2,str3 = strsplit(" ", msg)
				if (str1=="SET") then
					local nametemp = strsplit("-", self.db.profile.macroid[j][tonumber(str2)])
					if ( str1=="SET" and tonumber(str2) <= self.db.profile.numMacros[j] and str3~=nametemp) then
						TMM:Alter_Macro(str3,j,tonumber(str2))
					end
				end
			end
		end
	end
end

--"name" already in use (for Blizz MT)
function TMM:MacroIdContains(i,name)
	for j=1,10 do
		if (name==strsplit("-", self.db.profile.macroid[i][j])) then
			return j;
		end
	end
	return false;
end

--alter macro on Blizz MT change
function TMM:RAID_ROSTER_UPDATE()
	for j=1, 10 do
		if ( self.db.profile.btank[j] ) then
			local tank={}
			tank[1],tank[2],tank[3],tank[4],tank[5],tank[6],tank[7],tank[8],tank[9],tank[10] = GetPartyAssignment("maintank")
			local inuse = {false,false,false,false,false,false,false,false,false,false}
			local i=1
			while (tank[i]~=nil) do
				temp = TMM:MacroIdContains(j,GetUnitName("raid"..tank[i]))
				if (temp) then
					inuse[temp]=true
				end
				i=i+1
			end
			i=1
			while (tank[i]~=nil and self.db.profile.numMacros[j] >= i) do
				if( not TMM:MacroIdContains(j,GetUnitName("raid"..tank[i])) ) then
					for k=1,10 do
						if (not inuse[k] and self.db.profile.numMacros[j] >= k) then
							TMM:Alter_Macro(GetUnitName("raid"..tank[i]),j,k)
							break
						end
					end
				end
				i=i+1
			end
		end
	end
end

--announce
function TMM:COMBAT_LOG_ON()
	TMM:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end

function TMM:COMBAT_LOG_EVENT_UNFILTERED(_,_, subEvent, sourceGUID, _, _, _, destName, _, spellId,spellName)
	if sourceGUID == UnitGUID('player') and (subEvent=="SPELL_CAST_SUCCESS" or subEvent=="SPELL_HEAL" or subEvent=="SPELL_AURA_APPLIED")then
		if (spellId==35079 or spellId==59628 or spellId==57934 or spellId==379 or(spellId==34477 and subEvent=="SPELL_AURA_APPLIED")) then
			return
		end

		for i=1,10 do
			if (self.db.profile.announce[i] and self.db.profile.skills[i]==GetSpellInfo(spellId)) then
				chan, nr = strsplit(" ", self.db.profile.announceTo[i])
				if (chan=="CHANNEL") then
					SendChatMessage(format("%s %s!",spellName,destName), chan, nil, nr)
				elseif (chan ~= "smart") then
					SendChatMessage(format("%s %s!",spellName,destName), chan, nil, destName)
				else
					if GetNumRaidMembers() > 0 then
						SendChatMessage(format("%s %s!",spellName,destName), 'RAID')
					elseif GetNumPartyMembers() > 0 then
						SendChatMessage(format("%s %s!",spellName,destName), 'PARTY')
					end
				end
				TMM:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
				TMM:CancelAllTimers()
				TMM:ScheduleTimer("COMBAT_LOG_ON", 1)
			end
		end
	end
end

--Error ausgabe zu viele makros
	function TMM:MacroOverflow()
		DEFAULT_CHAT_FRAME:AddMessage("|cff33ff99TMM WARNING|r: You reached the maximum number of Macros")
		DEFAULT_CHAT_FRAME:AddMessage("--- no new macro added! ---")
	end

--apply settings
function TMM:ApplySettings(spec)
	if (self.db.profile.inuse[spec]) then
		local name, texture, macrobody
		local str1,str2,str3
			--Macro anzahl verringern wenn zuviele
			for i=(self.db.profile.numMacros[spec] + 1),10 do
				if GetMacroBody(self.db.profile.macroid[spec][i]) then DeleteMacro(self.db.profile.macroid[spec][i]) end
				self.db.profile.macroid[spec][i]= "";
			end
			--Macros erkennen die vorhanden sind aber dem addon nicht bekannt
			for i=37 , 54 do
				name = GetMacroInfo(i)
				str1,str2,str3 = nil,nil,nil
				if name~=nil then str1,str2,str3 = strsplit("-", name) end
				if ( str2 == self.db.profile.skills[spec] ) then
						if ( tonumber(str3)~=nil and name~=self.db.profile.macroid[spec][tonumber(str3)] and tonumber(str3)<=10 and tonumber(str3) >=1 ) then
							self.db.profile.macroid[spec][tonumber(str3)] = name
						end
				elseif ( str1 == self.db.profile.skills[spec] )  then
						if ( tonumber(str2)~=nil and name~=self.db.profile.macroid[spec][tonumber(str2)] and str3 == nil and tonumber(str2)<=10 and tonumber(str2) >=1 ) then
							self.db.profile.macroid[spec][tonumber(str2)] = name
						end
				end
			end
			--Macros Erstellen die dem Addon bekannt sind aber nicht vorhanden
			for i=1, self.db.profile.numMacros[spec] do
				if self.db.profile.macroid[spec][i] == "" then
					local icon
					if ( self.db.profile.custom[spec] ) then
						icon=self.db.profile.macroicon[spec][i]
					else icon = 1 end
					self.db.profile.macroid[spec][i]=format("%s-%i", self.db.profile.skills[spec], i)
					CreateMacro(self.db.profile.macroid[spec][i], icon, format("#showtooltip\n/use %s", self.db.profile.skills[spec]), 1);
				elseif (GetMacroBody(self.db.profile.macroid[spec][i])==nil) then
					local icon
					if ( self.db.profile.custom[spec] ) then
						icon=self.db.profile.macroicon[spec][i]
					else icon = 1 end
					CreateMacro(self.db.profile.macroid[spec][i], icon, format("#showtooltip\n/use  %s", self.db.profile.skills[spec]), 1)
				else TMButtonTxt[spec][i] = self.db.profile.macroid[spec][i] end
			end

			--Alle Macros neu schreiben
			for i=1, self.db.profile.numMacros[spec] do
				local icon
				if ( self.db.profile.custom[spec] ) then
					icon=self.db.profile.macroicon[spec][i]
				else icon = 1 end
				name = strsplit("-", self.db.profile.macroid[spec][i])
				if ( name~=self.db.profile.skills[spec] )then
					EditMacro(self.db.profile.macroid[spec][i], format("%s-%s-%i", name, self.db.profile.skills[spec], i), GetSpellorMacroIconInfo(icon), format("#showtooltip\n/use [@%s] %s", name, self.db.profile.skills[spec]),1)
				elseif ( name==self.db.profile.skills[spec] ) then
					EditMacro(self.db.profile.macroid[spec][i], format("%s-%i", self.db.profile.skills[spec], i), GetSpellorMacroIconInfo(icon), format("#showtooltip\n/use %s", self.db.profile.skills[spec]),1)
				end
			end
	--bei spec delete alle Macros der spec deleten
	elseif (self.db.profile.skills[spec] ~= "") then
		for i=1,self.db.profile.numMacros[spec] do
				if GetMacroBody(self.db.profile.macroid[spec][i]) then DeleteMacro(self.db.profile.macroid[spec][i]) end
				self.db.profile.macroid[spec][i]= "";
		end
	end

	--Menü aufräumen
	local buttoncnt = 1
	for j=1,10 do
		if (self.db.profile.inuse[j]) then
			for i=1,self.db.profile.numMacros[j] do
				local temp = format("%i-%i", j,i)
				TMisdButtons[temp] ={text=TMButtonTxt[j][i], dist=0, color="|cffffffff", tooltipText=""};
				TMisdMenu[buttoncnt] = temp;
				buttoncnt = buttoncnt + 1
			end
		end
	end
	TMisdMenu[buttoncnt] = nil
end

--addon start (/w options,getter,setter)
function TMM:OnEnable()

	if (GetLocale() == "deDE") then
		un= "Unbekannt"
	elseif (GetLocale() == "enUS" or GetLocale() == "enGB") then
		un= "Unknown"
	elseif (GetLocale() == "esES" or GetLocale() == "esMX") then
		un= "Desconocido"
	elseif (GetLocale() == "frFR") then
		un= "Inconnu"
	elseif (GetLocale() == "ruRU") then
		un= "Неизвестно"
	else
		un= "Unknown"
	end

	self:SecureHook("UnitPopup_ShowMenu");
	--options

	local function SetArrayValue(info, value)
		info.handler.db.profile[info[#info]][tonumber(info.arg)] = value
		self:ApplySettings(tonumber(info.arg))
		if ( info[#info]=="ora" ) then
			if (value) then
				TMM:RegisterEvent("CHAT_MSG_ADDON")
			else
				if ( not(info.handler.db.profile.ora[1] or
					 info.handler.db.profile.ora[2] or
					 info.handler.db.profile.ora[3] or
					 info.handler.db.profile.ora[4] or
					 info.handler.db.profile.ora[5] or
					 info.handler.db.profile.ora[6] or
					 info.handler.db.profile.ora[7] or
					 info.handler.db.profile.ora[8] or
					 info.handler.db.profile.ora[9] or
					 info.handler.db.profile.ora[10] )
				) then
					TMM:UnregisterEvent("CHAT_MSG_ADDON")
				end
			end
		elseif ( info[#info]=="announce" ) then
			if (value) then
				TMM:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
			else
				if ( not(info.handler.db.profile.announce[1] or
					 info.handler.db.profile.announce[2] or
					 info.handler.db.profile.announce[3] or
					 info.handler.db.profile.announce[4] or
					 info.handler.db.profile.announce[5] or
					 info.handler.db.profile.announce[6] or
					 info.handler.db.profile.announce[7] or
					 info.handler.db.profile.announce[8] or
					 info.handler.db.profile.announce[9] or
					 info.handler.db.profile.announce[10] )
				) then
					TMM:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
				end
			end
		elseif ( info[#info]=="btank" ) then
			if (value) then
				TMM:RegisterEvent("RAID_ROSTER_UPDATE")
			else
				if ( not(info.handler.db.profile.btank[1] or
					 info.handler.db.profile.btank[2] or
					 info.handler.db.profile.btank[3] or
					 info.handler.db.profile.btank[4] or
					 info.handler.db.profile.btank[5] or
					 info.handler.db.profile.btank[6] or
					 info.handler.db.profile.btank[7] or
					 info.handler.db.profile.btank[8] or
					 info.handler.db.profile.btank[9] or
					 info.handler.db.profile.btank[10] )
				) then
					TMM:UnregisterEvent("RAID_ROSTER_UPDATE")
				end
			end
		end

	end

	local function SetlfgValue(info, value)
		info.handler.db.profile[info[#info]][tonumber(info.arg)] = value
		self:ApplySettings(tonumber(info.arg))
		if ( info[#info]=="lfg" ) then
			if (value) then
				TMM:RegisterEvent("PLAYER_ROLES_ASSIGNED")
				info.options.args["Skillspecifics"..info.arg].args.lfgh.disabled=true
			else
				info.options.args["Skillspecifics"..info.arg].args.lfgh.disabled=false
				if ( not(info.handler.db.profile.lfg[1] or
					 info.handler.db.profile.lfg[2] or
					 info.handler.db.profile.lfg[3] or
					 info.handler.db.profile.lfg[4] or
					 info.handler.db.profile.lfg[5] or
					 info.handler.db.profile.lfg[6] or
					 info.handler.db.profile.lfg[7] or
					 info.handler.db.profile.lfg[8] or
					 info.handler.db.profile.lfg[9] or
					 info.handler.db.profile.lfg[10] or
					 info.handler.db.profile.lfgh[1] or
					 info.handler.db.profile.lfgh[2] or
					 info.handler.db.profile.lfgh[3] or
					 info.handler.db.profile.lfgh[4] or
					 info.handler.db.profile.lfgh[5] or
					 info.handler.db.profile.lfgh[6] or
					 info.handler.db.profile.lfgh[7] or
					 info.handler.db.profile.lfgh[8] or
					 info.handler.db.profile.lfgh[9] or
					 info.handler.db.profile.lfgh[10] )
				) then
					TMM:UnregisterEvent("PLAYER_ROLES_ASSIGNED")
				end
			end
		elseif ( info[#info]=="lfgh" ) then
			if (value) then
				TMM:RegisterEvent("PLAYER_ROLES_ASSIGNED")
				info.options.args["Skillspecifics"..info.arg].args.lfg.disabled=true
			else
				info.options.args["Skillspecifics"..info.arg].args.lfg.disabled=false
				if ( not(info.handler.db.profile.lfg[1] or
					 info.handler.db.profile.lfg[2] or
					 info.handler.db.profile.lfg[3] or
					 info.handler.db.profile.lfg[4] or
					 info.handler.db.profile.lfg[5] or
					 info.handler.db.profile.lfg[6] or
					 info.handler.db.profile.lfg[7] or
					 info.handler.db.profile.lfg[8] or
					 info.handler.db.profile.lfg[9] or
					 info.handler.db.profile.lfg[10] or
					 info.handler.db.profile.lfgh[1] or
					 info.handler.db.profile.lfgh[2] or
					 info.handler.db.profile.lfgh[3] or
					 info.handler.db.profile.lfgh[4] or
					 info.handler.db.profile.lfgh[5] or
					 info.handler.db.profile.lfgh[6] or
					 info.handler.db.profile.lfgh[7] or
					 info.handler.db.profile.lfgh[8] or
					 info.handler.db.profile.lfgh[9] or
					 info.handler.db.profile.lfgh[10] )
				) then
					TMM:UnregisterEvent("PLAYER_ROLES_ASSIGNED")
				end
			end
		end
	end

	local function GetArrayValue(info)
		value = info.handler.db.profile[info[#info]][tonumber(info.arg)]
		if ( info[#info]=="ora" ) then
			if (value) then
				TMM:RegisterEvent("CHAT_MSG_ADDON")
			else
				if ( not(info.handler.db.profile.ora[1] or
					 info.handler.db.profile.ora[2] or
					 info.handler.db.profile.ora[3] or
					 info.handler.db.profile.ora[4] or
					 info.handler.db.profile.ora[5] or
					 info.handler.db.profile.ora[6] or
					 info.handler.db.profile.ora[7] or
					 info.handler.db.profile.ora[8] or
					 info.handler.db.profile.ora[9] or
					 info.handler.db.profile.ora[10] )
				) then
					TMM:UnregisterEvent("CHAT_MSG_ADDON")
				end
			end
		elseif ( info[#info]=="announce" ) then
			if (value) then
				TMM:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
			else
				if ( not(info.handler.db.profile.announce[1] or
					 info.handler.db.profile.announce[2] or
					 info.handler.db.profile.announce[3] or
					 info.handler.db.profile.announce[4] or
					 info.handler.db.profile.announce[5] or
					 info.handler.db.profile.announce[6] or
					 info.handler.db.profile.announce[7] or
					 info.handler.db.profile.announce[8] or
					 info.handler.db.profile.announce[9] or
					 info.handler.db.profile.announce[10] )
				) then
					TMM:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
				end
			end
		elseif ( info[#info]=="btank" ) then
			if (value) then
				TMM:RegisterEvent("RAID_ROSTER_UPDATE")
			else
				if ( not(info.handler.db.profile.btank[1] or
					 info.handler.db.profile.btank[2] or
					 info.handler.db.profile.btank[3] or
					 info.handler.db.profile.btank[4] or
					 info.handler.db.profile.btank[5] or
					 info.handler.db.profile.btank[6] or
					 info.handler.db.profile.btank[7] or
					 info.handler.db.profile.btank[8] or
					 info.handler.db.profile.btank[9] or
					 info.handler.db.profile.btank[10] )
				) then
					TMM:UnregisterEvent("RAID_ROSTER_UPDATE")
				end
			end
		end
		return value
	end

	local function GetlfgValue(info)
		value = info.handler.db.profile[info[#info]][tonumber(info.arg)]
		if ( info[#info]=="lfg" ) then
			if (value) then
				TMM:RegisterEvent("PLAYER_ROLES_ASSIGNED")
				info.options.args["Skillspecifics"..info.arg].args.lfgh.disabled=true
			else
				info.options.args["Skillspecifics"..info.arg].args.lfgh.disabled=false
				if ( not(info.handler.db.profile.lfg[1] or
					 info.handler.db.profile.lfg[2] or
					 info.handler.db.profile.lfg[3] or
					 info.handler.db.profile.lfg[4] or
					 info.handler.db.profile.lfg[5] or
					 info.handler.db.profile.lfg[6] or
					 info.handler.db.profile.lfg[7] or
					 info.handler.db.profile.lfg[8] or
					 info.handler.db.profile.lfg[9] or
					 info.handler.db.profile.lfg[10] or
					 info.handler.db.profile.lfgh[1] or
					 info.handler.db.profile.lfgh[2] or
					 info.handler.db.profile.lfgh[3] or
					 info.handler.db.profile.lfgh[4] or
					 info.handler.db.profile.lfgh[5] or
					 info.handler.db.profile.lfgh[6] or
					 info.handler.db.profile.lfgh[7] or
					 info.handler.db.profile.lfgh[8] or
					 info.handler.db.profile.lfgh[9] or
					 info.handler.db.profile.lfgh[10] )
				) then
					TMM:UnregisterEvent("PLAYER_ROLES_ASSIGNED")
				end
			end
		elseif ( info[#info]=="lfgh" ) then
			if (value) then
				TMM:RegisterEvent("PLAYER_ROLES_ASSIGNED")
				info.options.args["Skillspecifics"..info.arg].args.lfg.disabled=true
			else
				info.options.args["Skillspecifics"..info.arg].args.lfg.disabled=false
				if ( not(info.handler.db.profile.lfg[1] or
					 info.handler.db.profile.lfg[2] or
					 info.handler.db.profile.lfg[3] or
					 info.handler.db.profile.lfg[4] or
					 info.handler.db.profile.lfg[5] or
					 info.handler.db.profile.lfg[6] or
					 info.handler.db.profile.lfg[7] or
					 info.handler.db.profile.lfg[8] or
					 info.handler.db.profile.lfg[9] or
					 info.handler.db.profile.lfg[10] or
					 info.handler.db.profile.lfgh[1] or
					 info.handler.db.profile.lfgh[2] or
					 info.handler.db.profile.lfgh[3] or
					 info.handler.db.profile.lfgh[4] or
					 info.handler.db.profile.lfgh[5] or
					 info.handler.db.profile.lfgh[6] or
					 info.handler.db.profile.lfgh[7] or
					 info.handler.db.profile.lfgh[8] or
					 info.handler.db.profile.lfgh[9] or
					 info.handler.db.profile.lfgh[10] )
				) then
					TMM:UnregisterEvent("PLAYER_ROLES_ASSIGNED")
				end
			end
		end
		return value
	end

	local function SetNewSkill(info, value)
		for i=1,10 do
			if (info.handler.db.profile.skills[i]== value) then
				DEFAULT_CHAT_FRAME:AddMessage("|cff33ff99TMM WARNING|r:TMM can only handle each skill once")
				DEFAULT_CHAT_FRAME:AddMessage("--- no new skill added! ---")
				return
			end
		end
		for i=1,10 do
			if(not info.handler.db.profile.inuse[i]) then
				info.handler.db.profile.inuse[i]= true
				info.handler.db.profile.skills[i]= value
				local specifics = info.options.args["Skillspecifics"..tostring(i)]
				specifics.name = value
				specifics.hidden = false
				specifics.name = value
				self:ApplySettings(i)
				self:ApplySettings(i)
				break
			end
			if(i==10) then
				DEFAULT_CHAT_FRAME:AddMessage("|cff33ff99TMM WARNING|r: TMM can only handle up to 10 different skills at once")
				DEFAULT_CHAT_FRAME:AddMessage("--- no new skill added! ---")
			end
		end
	end

	local function GetNewSkill(info)
			for i=1,10 do
				if(info.handler.db.profile.inuse[i]) then
					local specifics = info.options.args["Skillspecifics"..tostring(i)]
					specifics.name = info.handler.db.profile.skills[i]
					specifics.hidden = false
				end
			end
		return nil
	end

	local function deletespecifics(info)
		local i = tonumber(info.arg)
		test= info.options.args["Skillspecifics"..info.arg]
		test.hidden = true
		info.handler.db.profile.inuse[i] = false
		self:ApplySettings(i)
		info.handler.db.profile.macroid[i] = {"","","","","","","","","","",""}
		info.handler.db.profile.announce[i] = false
		info.handler.db.profile.announceTo[i] = "PARTY"
		info.handler.db.profile.ora[i] = false
		info.handler.db.profile.lfg[i] = false
		info.handler.db.profile.lfgh[i] = false
		info.handler.db.profile.btank[i] = false
		info.handler.db.profile.custom[i] = false
		info.handler.db.profile.macroicon[i] = {1,1,1,1,1,1,1,1,1,1}
		info.handler.db.profile.skills[i] = ""
		info.handler.db.profile.numMacros[i] = 1
	end

	local function GetnumMacros(info)
		local value = info.handler.db.profile[info[#info]][tonumber(info.arg)]
		local specifics = info.options.args["Skillspecifics"..info.arg]
			for i=1,10 do
				local thisspecifics = specifics.args["macroicon"..tostring(i)]
				if (i<=value)then
					thisspecifics.hidden=false
				else
					thisspecifics.hidden=true
				end
			end
		return value
	end

	local function SetnumMacros(info, value)
		local _,numperchar = GetNumMacros()
		if (numperchar==18 and info.handler.db.profile[info[#info]][tonumber(info.arg)] < value) then
				TMM:CancelAllTimers()
				TMM:ScheduleTimer("MacroOverflow", 1)
			return;
		end
		info.handler.db.profile[info[#info]][tonumber(info.arg)]= value
		local specifics = info.options.args["Skillspecifics"..info.arg]

		for i=1,10 do
			local thisspecifics = specifics.args["macroicon"..tostring(i)]
			if (i<=value)then
				thisspecifics.hidden=false
			else
				thisspecifics.hidden=true
			end
		end
		self:ApplySettings(tonumber(info.arg))
	end

	local function SetCustom(info, value)
		info.handler.db.profile[info[#info]][tonumber(info.arg)] = value
		local specifics = info.options.args["Skillspecifics"..info.arg]
		for i=1,10 do
			local thisspecifics = specifics.args["macroicon"..tostring(i)]
			thisspecifics.disabled=not value
		end
		self:ApplySettings(tonumber(info.arg))
	end

	local function GetCustom(info)
		local value = info.handler.db.profile[info[#info]][tonumber(info.arg)]
		local specifics = info.options.args["Skillspecifics"..info.arg]
		for i=1,10 do
			local thisspecifics = specifics.args["macroicon"..tostring(i)]
			thisspecifics.disabled=not value
		end
		return value
	end

	local function SetIcon(info, value)
		local specifics = info.options.args["Skillspecifics"..info.arg].args[info[#info-1]]
		info.handler.db.profile.macroicon[tonumber(info.arg)][specifics.order] = value
		specifics.args.icon.image=GetSpellorMacroIconInfo(value)
		self:ApplySettings(tonumber(info.arg))
	end

	local function GetIcon(info)
		local specifics = info.options.args["Skillspecifics"..info.arg].args[info[#info-1]]
		return info.handler.db.profile.macroicon[tonumber(info.arg)][specifics.order]
	end

	LoadAddOn("Blizzard_MacroUI")
	RefreshPlayerSpellIconInfo()
	local temp1 = 1
	for i = 1, 10000 do
		if not GetSpellorMacroIconInfo(i) then
			temp1 = i - 1
			break
		end
	end

	options = {
		name = "TyraMagicMacros",
		type = 'group',
		childGroups  = 'tab',
		handler = TMM,
		get = GetArrayValue,
		set = SetArrayValue,
		args = {
				Skillinput = {
					name = "add new skill (case sensitiv!)",
					desc = "Skill you want TyraMagicMacros to handle",
					order = 2,
					type = "input",
					get = GetNewSkill,
					set = SetNewSkill,
				},
				Skillspecifics1={
					name = "skillspecifics1",
					type = 'group',
					order = 11,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							func = deletespecifics,
							type = "execute",
							width= 'half',
							confirm = true,
							arg = "1",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "1",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "1",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "1",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "1",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "1",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "1",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "1",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "1",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[1][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "1",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics2={
					name = "skillspecifics",
					type = 'group',
					order = 12,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							width= 'half',
							func = deletespecifics,
							confirm = true,
							arg = "2",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "2",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "2",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "2",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "2",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "2",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "2",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "2",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "2",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[2][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "2",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics3={
					name = "skillspecifics",
					type = 'group',
					order = 13,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "3",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "3",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "3",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "3",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "3",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "3",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "3",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "3",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "3",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[3][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "3",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics4={
					name = "skillspecifics",
					type = 'group',
					order = 14,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "4",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "4",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "4",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "4",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "4",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "4",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "4",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "4",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "4",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[4][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "4",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics5={
					name = "skillspecifics",
					type = 'group',
					order = 15,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "5",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "5",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "5",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "5",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "5",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "5",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "5",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "5",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "5",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[5][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "5",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics6={
					name = "skillspecifics6",
					type = 'group',
					order = 16,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "6",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "6",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "6",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "6",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "6",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "6",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "6",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "6",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "6",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[6][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "6",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics7={
					name = "skillspecifics",
					type = 'group',
					order = 17,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "7",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "7",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "7",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "7",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "7",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "7",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "7",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "7",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "7",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "7",
										set = SetIcon,
										get = GetIcon,
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[7][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "7",
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics8={
					name = "skillspecifics",
					type = 'group',
					order = 18,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "8",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "8",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "8",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "8",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "8",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "8",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "8",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "8",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "8",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[8][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "8",
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics9={
					name = "skillspecifics9",
					type = 'group',
					order = 19,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "9",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "9",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "9",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "9",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "9",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "9",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "9",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "9",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "9",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[9][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "9",
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
				Skillspecifics10={
					name = "skillspecifics",
					type = 'group',
					order = 20,
					childGroups  = 'tab',
					hidden = true,
					args = {
						deleteButton ={
							name = "Delete",
							desc = "Are you sure you want to delete all macros of this skill ?",
							order = 1,
							type = "execute",
							func = deletespecifics,
							confirm = true,
							width= 'half',
							arg = "10",
						},
						numMacros = {
							name = "Macros",
							desc = "Numbers of Macros you want TyraMagicMacros to create and handle for this skill",
							order = 2,
							type = "range",
							arg = "10",
							get = GetnumMacros,
							set = SetnumMacros,
							min = 1, max = 10, step = 1,
						},
						anounceheader= {
							name = "Announce",
							order = 3,
							type = "header",
						},
						announce = {
							name = "Announce",
							desc = "Announce Cast to selected channel",
							order = 4,
							type = "toggle",
							arg = "10",
						},
						announceTo = {
							name = "Announce to",
							desc = "Announce Cast to selected channel",
							order = 5,
							type = "select",
							values = {["OFFICER"] = "officers", ["GUILD"] = "guild", ["RAID_WARNING"] = "raidwarning", ["RAID"] = "raid", ["YELL"] = "yell", ["PARTY"] = "party", ["SAY"] = "say", ["WHISPER"] = "whisper",
							["BATTLEGROUND"] = "battleground", ["CHANNEL 5"]= "Channel 5", ["CHANNEL 6"]= "Channel 6", ["CHANNEL 7"]= "Channel 7", ["CHANNEL 8"]= "Channel 8", ["CHANNEL 9"]= "Channel 9", ["smart"]= "smart"},
							arg = "10",
						},
						autoheader= {
							name = "Automations",
							order = 6,
							type = "header",
						},
						lfg = {
							name = "Dungeon Finder Tank",
							desc = "will set the Tank of the random group to Macro 1 automatically",
							order = 7,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "10",
						},
						lfgh = {
							name = "Dungeon Finder Healer",
							desc = "will set the Healer of the random group to Macro 1 automatically",
							order = 8,
							get = GetlfgValue,
							set = SetlfgValue,
							type = "toggle",
							arg = "10",
						},
						btank = {
							name = "Blizzard Maintank",
							desc = "will set the Blizzard Maintank on Macro 1-10 automatically",
							order = 9,
							type = "toggle",
							arg = "10",
						},
						ora = {
							name = "oRA/CTRA Tank",
							desc = "will set the oRA/CTRA Tanks on Macro 1-10 automatically",
							order = 10,
							type = "toggle",
							arg = "10",
						},
						skillheader= {
							name = "Custom skill icons",
							order = 11,
							type = "header",
						},
						custom = {
							name = "Use custom Icons",
							desc = "Use custom Icons for Macros",
							order = 13,
							type = "toggle",
							get = GetCustom,
							set = SetCustom,
							arg = "10",
						},
						macroicon1 = {
							name = "Macro 1 Icon",
							type = 'group',
							order=1,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][1]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon2 = {
							name = "Macro 2 Icon",
							type = 'group',
							order=2,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][2]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon3 = {
							name = "Macro 3 Icon",
							type = 'group',
							order=3,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][3]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon4 = {
							name = "Macro 4 Icon",
							type = 'group',
							order=4,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][4]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon5 = {
							name = "Macro 5 Icon",
							type = 'group',
							order=5,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][5]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon6 = {
							name = "Macro 6 Icon",
							type = 'group',
							order=6,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][6]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon7 = {
							name = "Macro 7 Icon",
							type = 'group',
							order=7,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][7]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon8 = {
							name = "Macro 8 Icon",
							type = 'group',
							order=8,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][8]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon9 = {
							name = "Macro 9 Icon",
							type = 'group',
							order=9,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][9]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
						macroicon10 = {
							name = "Macro 10 Icon",
							type = 'group',
							order=10,
							args = {
									icon = {
										name = "",
										order= 20,
										image = GetSpellorMacroIconInfo(self.db.profile.macroicon[10][10]),
										type = 'execute',
										width = "half"
									},
									iconselect = {
										name = "Icon Index",set = SetIcon,get = GetIcon,
										type = "range",
										order= 10,
										arg = "10",
										min = 1, max = temp1, step = 1
									},
							}
						},
					},
				},
			}
	}

	config:RegisterOptionsTable("TyraMagicMacros", options)
	dialog:AddToBlizOptions("TyraMagicMacros", "TyraMagicMacros")
	LibStub("AceConfigRegistry-3.0"):NotifyChange("TyraMagicMacros");

	for i=1,10 do
		self:ApplySettings(i)
	end
	if (self.db.profile.lfg[1] or
		self.db.profile.lfg[2] or
		self.db.profile.lfg[3] or
		self.db.profile.lfg[4] or
		self.db.profile.lfg[5] or
		self.db.profile.lfg[6] or
		self.db.profile.lfg[7] or
		self.db.profile.lfg[8] or
		self.db.profile.lfg[9] or
		self.db.profile.lfg[10]
	) then
		TMM:RegisterEvent("PLAYER_ROLES_ASSIGNED")
	end
	if (self.db.profile.lfgh[1] or
		self.db.profile.lfgh[2] or
		self.db.profile.lfgh[3] or
		self.db.profile.lfgh[4] or
		self.db.profile.lfgh[5] or
		self.db.profile.lfgh[6] or
		self.db.profile.lfgh[7] or
		self.db.profile.lfgh[8] or
		self.db.profile.lfgh[9] or
		self.db.profile.lfgh[10]
	) then
		TMM:RegisterEvent("PLAYER_ROLES_ASSIGNED")
	end
	if (self.db.profile.ora[1] or
		self.db.profile.ora[2] or
		self.db.profile.ora[3] or
		self.db.profile.ora[4] or
		self.db.profile.ora[5] or
		self.db.profile.ora[6] or
		self.db.profile.ora[7] or
		self.db.profile.ora[8] or
		self.db.profile.ora[9] or
		self.db.profile.ora[10]
	) then
		TMM:RegisterEvent("CHAT_MSG_ADDON")
	end
	if (self.db.profile.announce[1] or
		self.db.profile.announce[2] or
		self.db.profile.announce[3] or
		self.db.profile.announce[4] or
		self.db.profile.announce[5] or
		self.db.profile.announce[6] or
		self.db.profile.announce[7] or
		self.db.profile.announce[8] or
		self.db.profile.announce[9] or
		self.db.profile.announce[10]
	) then
		TMM:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
	end
	if (self.db.profile.btank[1] or
		self.db.profile.btank[2] or
		self.db.profile.btank[3] or
		self.db.profile.btank[4] or
		self.db.profile.btank[5] or
		self.db.profile.btank[6] or
		self.db.profile.btank[7] or
		self.db.profile.btank[8] or
		self.db.profile.btank[9] or
		self.db.profile.btank[10]
	) then
		TMM:RegisterEvent("RAID_ROSTER_UPDATE")
	end
end

-- TMM Button clicked
local function TMM_Button_Onclick(self, info)
	assert(info);
	local button = info.button; assert(button);
	local name = info.name or UnitName(info.unit); assert(name);
	specific,numMacro = strsplit("-", button)
	TMM:Alter_Macro(name,tonumber(specific),tonumber(numMacro));
	--assuming button names "1-1" - "10-10"
end

-- draw context menu
function TMM:UnitPopup_ShowMenu(dropdownMenu, which, unit, name, userData)
	if (InCombatLockdown()==nil and unit ~=nil) then
		local thisName = name or UnitName(unit);
		which = gsub(which, "PB4_", "");
		if ((not UnitPlayerOrPetInRaid(unit)) and (not UnitPlayerOrPetInParty(unit)) and ( not UnitIsUnit(unit, "player")) and ( not UnitIsUnit(unit, "pet")) ) then return; end
		if (UIDROPDOWNMENU_MENU_LEVEL > 1) then return; end
		local info = UIDropDownMenu_CreateInfo();
		for _,v in ipairs(TMisdMenu) do
			info.text=TMisdButtons[v].text;
			info.value=v;
			info.owner=which;
			info.func=TMM_Button_Onclick;
			info.notCheckable=1;
			info.arg1 = {["button"]=v, ["unit"]=unit, ["name"]=name};
			info.tooltipTitle = TMisdButtons[v].text;
			info.tooltipText = TMisdButtons[v].tooltipText;
			UIDropDownMenu_AddButton(info)
		end
	end
end