
local _G = getfenv(0)

if ( GetLocale() == "zhCN" ) then
	tCC_Optionlocal = {
		Title = "tCC 设置",
		Config = "开启",
		Shine = "开启闪光效果",
		HideCD = "隐藏系统动画",
		HideCD_title = "隐藏系统的转圈效果",
		Center = "开启中部提示",
		CMode = "中部加亮",
		Time = "闪光时间:",
		Time_title = "闪光效果持续时间(单位:秒)",
		Scale = "闪光大小:",
		Style = "闪光材质:",
		CTime = "中部时间:",
		CTime_title = "中部提示的持续时间",
		CScale = "中部大小:",
		CAlpha = "中部透明:",
		CAlpha_title = "中部提示的初始透明度",
		Size = "字体大小:",
		Point = "计时位置:",
		Font = "字体文件",
		Min = "时间下限",
		Min_title = "低于此值的冷却时间不显示(单位:秒)",
		Max = "时间上限",
		Max_title = "Buff计时剩余时间低于此值才开始显示\n设为 0 时不设上限(单位:秒)",
		Move = "移动中部",
		Action = "动作条",
		Pet = "宠物条",
		Spell = "技能书",
		Item = "背包",
		Buff = "Buff",
		StyleString = {"技能图标","系统","圆形","爆炸","心型"},
		PointString = {"左上","上","右上","左","中","右","左下","下","右下"},
		Font1 = "字体未设置，",
		Font2 = "为无效字体，请检查拼写！",
		Range = "超出距离",
		Mana = "法力不足",
		Usable = "不可用",
		Other = "其它",
		Type = "精确时间",
		Type_title = "1分钟到10分钟之间的时间显示为X:XX的形式"
	}
elseif ( GetLocale() == "zhTW" ) then
	tCC_Optionlocal = {
		Title = "tCC 設置",
		Config = "開啟",
		Shine = "開啟閃光效果",
		HideCD = "隱藏系統動畫",
		Center = "開啟中部提示",
		CMode = "中部加亮",
		Time = "閃光時間:",
		Scale = "閃光大小:",
		Style = "閃光材質:",
		CTime = "中部時間:",
		CScale = "中部大小:",
		CAlpha = "中部透明:",
		Size = "字體大小: ",
		Point = "計時位置:",
		Font = "字體文件",
		Min = "時間下限",
		Max = "時間上限",
		Move = "移動中部",
		Action = "動作條",
		Pet = "寵物條",
		Spell = "技能書",
		Item = "背包",
		Buff = "Buff",
		StyleString = {"技能圖標","系統", "圓形","爆炸","心型"},
		PointString = {"左上","上", "右上","左","中","右","左下","下","右下"},
		Font1 = "字體未設置，",
		Font2 = "為無效字體，請檢查拼寫！",
		Range = "超出距離",
		Mana = "法力不足",
		Usable = "不可用",
		Other = "其它",
		Type = "精確時間",
	}
elseif ( GetLocale() == "koKR" ) then
	tCC_Optionlocal = {
		Title = "tCC 옵션",
		Config = "사용",
		Shine = "반짝임 효과 사용",
		HideCD = "기본 재사용 시간 숨김",
		Center = "중앙 아이콘 사용",
		CMode = "중앙 밝게",
		Time = "반짝임 시간:",
		Scale = "반짝임 크기:",
		Style = "반짝임 무늬:",
		CTime = "아이콘 시간:",
		CScale = "아이콘 크기:",
		CAlpha = "아이콘 투명도:",
		Size = "글꼴 크기:",
		Point = "위치 :",
		Font = "글꼴체",
		Min = "최소 시간",
		Max = "최대 시간",
		Move = "중앙 아이콘 이동",
		Action = "바",
		Pet = "소환수",
		Spell = "마멉책",
		Item = "가방",
		Buff = "버프",
		StyleString = {"아이콘","기본","원형","폭격","하트"},
		PointString = {"좌측상단","상단","우측상단","좌측","중앙","우측","좌측하단","하단","우측하단"},
		Font1 = "설치되지 않은 글꼴입니다.",
		Font2 = "무효한 글꼴입니다. 글꼴 이름을 체크하세요!",
		Range = "사거리 벗어남",
		Mana = "마나 부족",
		Usable = "사용할 수 없음",
		Other = "기타",
		Type = "분:초",
	}
else
	tCC_Optionlocal = {
		Title = "tCC Options",
		Config = "Open",
		Shine = "Open Shine",
		HideCD = "Hide Original",
		Center = "Open Center",
		CMode = "Center Brightly",
		Time = "Shine Time:",
		Scale = "Shine Scale:",
		Style = "Shine Style:",
		CTime = "Center Time:",
		CScale = "Center Scale:",
		CAlpha = "Center Alpha:",
		Size = "Center Scale:",
		Point = "Position :",
		Font = "Font File",
		Min = "Time Floor",
		Max = "Time Ceil",
		Move = "Move Center",
		Action = "Bar",
		Pet = "Pet",
		Spell = "SpellBook",
		Item = "Bag",
		Buff = "Buff",
		StyleString = {"Spell Icon","Original","Circular","Bombings","Heart"},
		PointString = {"Top Left","Top","Top Right","Left","Center","Right","Bottom Left","Bottom","Bottom Right"},
		Font1 = "Fonts not installed,",
		Font2 = "Invalid font, Please check spelling!",
		Range = "Beyond the distance",
		Mana = "Not Enough Mana",
		Usable = "Not available",
		Other = "Other",
		Type = "Precise time",
	}
end

tCC_Option = CreateFrame("Frame",nil,UIParent)
tCC_Option:Hide()
tCC_Option.index = "Action"

function tCC_Option_EditBox_OnEscapePressed()
	this:SetText(tCC[tCC_Option.index][string.lower(this.index)])
	this:ClearFocus()
end

function tCC_Option_EditBox_OnMouseUp()
	if this.disable then
		this:ClearFocus()
	end
end

function tCC_Option_CheckButton_OnClick()
	local check = this:GetChecked()
	tCC[tCC_Option.index][this.var] = check
	tCC_Option_UpdateEnOrDis(this.auto, check)
end

function tCC_Option_Button_OnClick()
	_G["tCC_Option"..tCC_Option.index]:Enable()
	this:Disable()
	tCC_Option.index = this.index
	tCC_Option_LoadOptions(tCC_Option.index)
end

function tCC_Option_Slider_OnValueChange()
	local value = this:GetValue()
	if this.disable then
		if tCC[tCC_Option.index][this.var] ~= value then
			this:SetValue(tCC[tCC_Option.index][this.var])
		end
	else
		tCC[tCC_Option.index][this.var] = value
		if math.floor(value) ~= value then
			value = math.floor(value * 100) / 100
		end
		if this.string then
			value = this.string[value] or value
		end
		this.font:SetText(this.text .. value)
	end
end

local function tCC_Option_Enable(frame)
	local type = frame:GetObjectType()
	if type == "Button" then
		frame:Enable()
	elseif type == "Slider" then
		OptionsFrame_EnableSlider(frame)
		frame.disable = nil
	elseif type == "CheckButton" then
		OptionsFrame_EnableCheckBox(frame)
	elseif type == "EditBox" then
		frame:ClearFocus()
		frame.disable = nil
		_G[frame:GetName() .. "Text"]:SetVertexColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
	end
end

local function tCC_Option_Disable(frame)
	local type = frame:GetObjectType()
	if type == "Button" then
		frame:Disable()
	elseif type == "Slider" then
		OptionsFrame_DisableSlider(frame)
		frame.disable = true
	elseif type == "CheckButton" then
		OptionsFrame_DisableCheckBox(frame)
	elseif type == "EditBox" then
		frame:ClearFocus()
		frame.disable = true
		_G[frame:GetName() .. "Text"]:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
	end
end

function tCC_Option_UpdateEnOrDis(auto, check)
	if auto then
		local set
		if check  then
			set = tCC_Option_Enable
		else
			set = tCC_Option_Disable
		end
		for _, frame in ipairs(auto) do
			local button = _G["tCC_Option"..frame]
			set(button)
			tCC_Option_UpdateEnOrDis(button.auto, check)
		end
	end
end

local function tCC_OptionSliderSetValue(frame, value)
	if frame:IsVisible() and value and frame:GetValue() ~= value then
		frame:SetValue(value)
	end
end

local function tCC_Option_CheckButtonSetChecked(frame, check)
	local value = frame:GetChecked()
	if value == 1 then value = true else value = false end
	if frame:IsVisible() and value ~= check then
		frame:SetChecked(check)
		tCC_Option_UpdateEnOrDis(frame.auto, check)
	end
end

local function tCC_Option_EditBoxSetText(frame, text)
	if frame:IsVisible() and text and text ~= frame:GetText() then
		frame:SetText(text)
	end
end

local function tCC_OptionColor_OnClick()
	if ColorPickerFrame:IsShown() then
		ColorPickerFrame:Hide()
	else
		ColorPickerFrame.index = this.index
		ColorPickerFrame.hasOpacity = nil
		ColorPickerFrame.previousValues = {r = tCC.Color[this.index].r, g = tCC.Color[this.index].g, b = tCC.Color[this.index].b}

		ColorPickerFrame.func = tCC_OptionColor_OnColorChange
		ColorPickerFrame.cancelFunc = function() tCC_OptionColor_OnColorChange(ColorPickerFrame.previousValues, ColorPickerFrame.index) end

		ColorPickerFrame:SetColorRGB(tCC.Color[this.index].r, tCC.Color[this.index].g, tCC.Color[this.index].b)

		ShowUIPanel(ColorPickerFrame)
	end
end

function tCC_OptionColor_OnColorChange(rgb, index)
	local r, g, b
	if rgb then
		r = rgb.r; g = rgb.g; b = rgb.b
	else
		r, g, b = ColorPickerFrame:GetColorRGB()
		index = ColorPickerFrame.index
	end

	tCC.Color[index].r = r
	tCC.Color[index].g = g
	tCC.Color[index].b = b

	getglobal("tCC_Option"..index.."NormalTexture"):SetVertexColor(r, g, b)
end

function tCC_Option_LoadOptions(index)
	local show, frame = {"Range","Mana","Usable","Max","Min","Config","Point","HideCD","Center","Type","CTime","CScale","Move","Shine","Time","Scale","Style","CAlpha","CMode","Font","Size","Point"}
	for _, frame in ipairs(show) do
		frame = _G["tCC_Option" .. frame]
		if frame and not frame:IsVisible() then
			frame:Show()
		end
	end
	local button = _G["tCC_Option"..index]
	for _, frame in ipairs(button.auto) do
		frame = _G["tCC_Option"..frame]
		if frame and frame:IsVisible() then
			frame:Hide()
		end
	end

	local min, _ = tCC_OptionStyle:GetMinMaxValues()
	if button.stylemin and min ~= button.stylemin then
		tCC_OptionStyle:SetMinMaxValues(button.stylemin, 5)
		_G["tCC_OptionStyle".."Low"]:SetText(button.stylemin)
	end

	if index ~= "Other" then
		local value = tCC[index]

		tCC_Option_CheckButtonSetChecked(tCC_OptionShine,  value.shine)
		tCC_Option_CheckButtonSetChecked(tCC_OptionCenter, value.center)
		tCC_Option_CheckButtonSetChecked(tCC_OptionHideCD, value.hide)
		tCC_Option_CheckButtonSetChecked(tCC_OptionConfig, value.config)
		tCC_Option_CheckButtonSetChecked(tCC_OptionCMode,  value.cmode)

		tCC_OptionSliderSetValue(tCC_OptionTime,   value.time)
		tCC_OptionSliderSetValue(tCC_OptionScale,  value.scale)
		tCC_OptionSliderSetValue(tCC_OptionStyle,  value.style)
		tCC_OptionSliderSetValue(tCC_OptionCTime,  value.ctime)
		tCC_OptionSliderSetValue(tCC_OptionCScale, value.cscale)
		tCC_OptionSliderSetValue(tCC_OptionPoint,  value.point)
		tCC_OptionSliderSetValue(tCC_OptionCAlpha, value.calpha)
		tCC_OptionSliderSetValue(tCC_OptionSize,   value.size)

		tCC_Option_EditBoxSetText(tCC_OptionFont, value.font)
		tCC_Option_EditBoxSetText(tCC_OptionMin,  value.min)
		tCC_Option_EditBoxSetText(tCC_OptionMax,  value.max)
	elseif tdRange_GetColor then
		tCC_OptionColor_OnColorChange(tCC.Color.Range, "Range")
		tCC_OptionColor_OnColorChange(tCC.Color.Mana, "Mana")
		tCC_OptionColor_OnColorChange(tCC.Color.Usable, "Usable")
		tCC_Option_CheckButtonSetChecked(tCC_OptionType,  tCC.type)
	end

	if tCC_Move and tCC_Move:IsVisible() then tCC_Move:Hide() end
end

function tCC_Option_Init()
	tCC_Option:SetWidth(300); tCC_Option:SetHeight(410);
	tCC_Option:SetPoint("CENTER")
	tCC_Option:SetFrameStrata("LOW")
	tCC_Option:SetToplevel(true)
	tCC_Option:SetMovable(true)
	tCC_Option:SetClampedToScreen(true)
	tCC_Option:SetBackdrop( {
		bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
		edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16,
		insets = { left = 5, right = 5, top = 5, bottom = 5 }
	});
	tCC_Option:SetBackdropColor(0,0,0)
	tCC_Option:EnableMouse(true)
	tCC_Option:RegisterForDrag("LeftButton")
	tCC_Option:SetScript("OnDragStart",function() this:StartMoving() end)
	tCC_Option:SetScript("OnDragStop",function() this:StopMovingOrSizing() end)

	tCC_Option:CreateFontString("tCC_OptionTitle", "ARTWORK", "SystemFont")
	tCC_OptionTitle:SetPoint("TOP",0,-10)
	tCC_OptionTitle:SetText(tCC_Optionlocal.Title)

	local tCC_Option_Buttons = {
		{name="Close",type="Button",inherits="UIPanelCloseButton",
			point="TOPRIGHT",},
		{name="Reset",type="Button",inherits="UIPanelButtonTemplate",text=RESET,
			width=50, height=20,func=function()
					tCC = tCC_GetDefault()
					tCC_Option_LoadOptions(tCC_Option.index)
				end,
			point="TOPLEFT",x=5,y=-5},

		{name="Config",type="CheckButton",var="config",auto={"Shine","Center","HideCD","Size","Point","Min","Max","Font"},
			point="TOPLEFT",x=20,y=-35},
		{name="Shine",type="CheckButton",var="shine",auto={"Time","Scale","Style"},
			point="LEFT",relative="Config",rpoint="RIGHT", x=100},
		{name="Center",type="CheckButton",var="center",auto={"CTime","CScale","Move","CAlpha","CMode"},
			point="TOPLEFT",relative="Config",rpoint="BOTTOMLEFT"},
		{name="HideCD",type="CheckButton",var="hide",
			point="TOPLEFT",relative="Shine",rpoint="BOTTOMLEFT"},
		{name="CMode",type="CheckButton",var="cmode",
			point="TOPLEFT",relative="Center",rpoint="BOTTOMLEFT"},
		{name="Type",type="CheckButton",func=function() if this:GetChecked() then tCC.type=true else tCC.type=nil end end,
			point="TOPLEFT",x=20,y=-35},

		{name="Time",type="Slider",min=0.00,max=5.00,step=0.01,var = "time",
			point="TOPLEFT",relative="CMode",rpoint="BOTTOMLEFT",y=-10,x=5},
		{name="Scale",type="Slider",min=36,max=500,step=1,var = "scale",
			point="TOPLEFT",relative="Time",rpoint="BOTTOMLEFT",y=-10},
		{name="Style",type="Slider",min=1,max=5,step=1,var = "style",string=tCC_Optionlocal.StyleString,
			point="TOPLEFT",relative="Scale",rpoint="BOTTOMLEFT",y=-10},

		{name="CTime",type="Slider",min=0.00,max=5.00,step=0.01,var = "ctime",
			point="TOPLEFT",relative="Style",rpoint="BOTTOMLEFT",y=-10},
		{name="CScale",type="Slider",min=50,max=200,step=1,var = "cscale",
			point="TOPLEFT",relative="CTime",rpoint="BOTTOMLEFT",y=-10},
		{name="CAlpha",type="Slider",min=0,max=1,step=0.01,var = "calpha",
			point="TOPLEFT",relative="CScale",rpoint="BOTTOMLEFT",y=-10},

		{name="Size",type="Slider",min=1,max=36,step=1,var = "size",
			point="TOPLEFT",relative="CAlpha",rpoint="BOTTOMLEFT",y=-10},
		{name="Point",type="Slider",min=1,max=9,step=1,var = "point",string=tCC_Optionlocal.PointString,
			point="TOPLEFT",relative="Size",rpoint="BOTTOMLEFT",y=-10},

		{name="Font",type="EditBox",width=160,height=20,var="font",func=function()
				if(not tCCTestFont) then
					CreateFont("tCCTestFont")
				end
				if( tCCTestFont:SetFont(this:GetText(), tCC[tCC_Option.index].size) ) then
					tCC[tCC_Option.index].font = this:GetText()
				else
					DEFAULT_CHAT_FRAME:AddMessage("tCC: |cFFFF0000"..tCC_Optionlocal.Font1..this:GetText()..tCC_Optionlocal.Font2.."|r")
					this:SetText(tCC[tCC_Option.index].font)
				end
				this:ClearFocus()
			end,
			point="TOPLEFT",relative="Point",rpoint="BOTTOMLEFT",y=-20},
		{name="Min",type="EditBox",width=50,height=20,var="min",letter=5,numonly=true,func=function()
				local value = tonumber(this:GetText())
				if value then
					tCC[tCC_Option.index].min = value
				else
					this:SetValue(tostring(tCC[tCC_Option.index].min))
				end
				this:ClearFocus()
			end,
			point="TOPLEFT",relative="Font",rpoint="BOTTOMLEFT",y=-10,},
		{name="Max",type="EditBox",width=50,height=20,var="max",letter=5,numonly=true,func=function()
				local value = tonumber(this:GetText())
				if value then
					tCC[tCC_Option.index].max = value
				else
					this:SetValue(tostring(tCC[tCC_Option.index].max))
				end
				this:ClearFocus()
			end,
			point="LEFT",relative="Min",rpoint="RIGHT",x=70,},

		{name="Move",type="Button",inherits="UIPanelButtonTemplate",
			width=100, height=20, func=tCC_CenterMove,
			point="LEFT",relative="Min",rpoint="RIGHT",x=100,},

		{name="Action",type="Button",point="TOPRIGHT",y=-70,       rpoint="TOPLEFT",auto={"Range","Mana","Usable","Max","Point","Type"},stylemin=1},
		{name="Pet",   type="Button",point="TOP",relative="Action",rpoint="BOTTOM", auto={"Range","Mana","Usable","Max","Point","Type"},stylemin=2},
		{name="Spell", type="Button",point="TOP",relative="Pet",   rpoint="BOTTOM", auto={"Range","Mana","Usable","Max","Point","Type","Center","CTime","CScale","Move","CAlpha","CMode"},stylemin=2},
		{name="Item",  type="Button",point="TOP",relative="Spell", rpoint="BOTTOM", auto={"Range","Mana","Usable","Max","Point","Type","Center","CTime","CScale","Move","CAlpha","CMode"},stylemin=2},
		{name="Buff",  type="Button",point="TOP",relative="Item",  rpoint="BOTTOM", auto={"Range","Mana","Usable","Min","Center","Type","Shine","Scale","Style","Time","CTime","CScale","Move","CAlpha","CMode"},stylemin=2},
		{name="Other", type="Button",point="TOP",relative="Buff",rpoint="BOTTOM",auto={"Style","Min","Max","Font","Size","Point","Center","Shine","Scale","Time","CTime","CScale","Move","CAlpha","CMode","Config","HideCD",}}
	}
	if tdRange_GetColor then
		local i = table.getn(tCC_Option_Buttons)
		tCC_Option_Buttons[i+1] = {name="Range", type="Button",func=tCC_OptionColor_OnClick,point="TOPLEFT",relative="Type",rpoint="BOTTOMLEFT",inherits="tCC_OptionColorPickerTemplate",}
		tCC_Option_Buttons[i+2] = {name="Mana",  type="Button",func=tCC_OptionColor_OnClick,point="TOPLEFT",relative="Range",rpoint="BOTTOMLEFT",inherits="tCC_OptionColorPickerTemplate",}
		tCC_Option_Buttons[i+3] = {name="Usable",type="Button",func=tCC_OptionColor_OnClick,point="TOPLEFT",relative="Mana",rpoint="BOTTOMLEFT",inherits="tCC_OptionColorPickerTemplate",}
	end

	local button, text, name, value
	for _, value in ipairs(tCC_Option_Buttons) do
		if not value.inherits then
			if value.type == "CheckButton" then
				value.inherits = "tCC_OptionCheckButtonTemplate"
			elseif value.type == "Slider" then
				value.inherits = "tCC_OptionSliderTemplate"
			elseif value.type == "EditBox" then
				value.inherits = "tCC_OptionEditBoxTemplate"
			elseif value.type == "Button" then
				value.inherits = "tCC_OptionButtonTemplate"
			end
		end
		button = CreateFrame(value.type, "tCC_Option"..value.name, tCC_Option, value.inherits)
		if value.width then
			button:SetWidth(value.width)
		end
		if value.height then
			button:SetHeight(value.height)
		end
		if value.point then
			if value.relative then
				value.relative = "tCC_Option"..value.relative
			end
			button:SetPoint(value.point, value.relative or tCC_Option, value.rpoint or value.point, value.x or 0, value.y or 0)
		end

		if value.type == "Button" then
			button:SetText(value.text or tCC_Optionlocal[value.name] or "")
		else
			button.font = _G[button:GetName().."Text"]
			button.font:SetText(value.text or tCC_Optionlocal[value.name] or "")
		end

		button.var = value.var or nil
		button.string = value.string or nil
		button.auto = value.auto or nil
		button.index = value.name or nil
		button.stylemin = value.stylemin or nil

		if value.type == "Slider" then
			button.text = value.text or tCC_Optionlocal[value.name] or ""
			_G["tCC_Option"..value.name.."Text"]:ClearAllPoints()
			_G["tCC_Option"..value.name.."Text"]:SetPoint("LEFT",button,"RIGHT",0,0)
			_G["tCC_Option"..value.name.."Low"]:SetText(value.min)
			_G["tCC_Option"..value.name.."High"]:SetText(value.max)
			button:SetMinMaxValues(value.min, value.max)
			button:SetValueStep(value.step)
		elseif value.type == "EditBox" then
			if value.letter then button:SetMaxLetters(value.letter) end
			if value.numonly then button:SetNumeric(value.numonly) end
		end
		if value.func then
			if value.type == "CheckButton" then
				button:SetScript("OnClick", value.func)
			elseif value.type == "Slider" then
				button:SetScript("OnValueChange", value.func)
			elseif value.type == "EditBox" then
				button:SetScript("OnEnterPressed", value.func)
			elseif value.type == "Button" then
				button:SetScript("OnClick", value.func)
			end
		end
		local title = value.title or tCC_Optionlocal[value.name .. "_title"] or nil
		if title then
			button.title = title
			button:SetScript("OnEnter",function() GameTooltip:SetOwner(this, "ANCHOR_RIGHT");GameTooltip:SetText(this.title) end)
			button:SetScript("OnLeave",function() GameTooltip:Hide() end)
		end
	end
	tCC_Option:Show()

	_G["tCC_OptionAction"]:Disable()
	tCC_Option_LoadOptions("Action")
	tCC_Option.ready = true
end

function tCC_CenterMove()
	if tCC_Move and tCC_Move:IsVisible() then
		tCC_Move:Hide()
	else
		if not tCC_Move then
			tCC_Move = CreateFrame("Frame",nil,UIParent)
			tCC_Move:SetClampedToScreen(true)
			tCC_Move:EnableMouse(true)
			tCC_Move:SetMovable(true)
			tCC_Move:RegisterForDrag("LeftButton")
			tCC_Move:SetScript("OnDragStart",function() this:StartMoving() end)
			tCC_Move:SetScript("OnDragStop",function()
				this:StopMovingOrSizing();
				local p,_,s,x,y = this:GetPoint()
				tCC[tCC_Option.index].x = x
				tCC[tCC_Option.index].y = y
				tCC[tCC_Option.index].p = p
				tCC[tCC_Option.index].s = s
			end)
			tCC_Move.texture = tCC_Move:CreateTexture(nil,"ARTWORK")
			tCC_Move.texture:SetAllPoints(tCC_Move)
			tCC_Move.texture:SetTexture("Interface\\Icons\\INV_Misc_Head_Dragon_01")
		end

		tCC_Move:SetWidth(tCC[tCC_Option.index].cscale);
		tCC_Move:SetHeight(tCC[tCC_Option.index].cscale);
		tCC_Move:ClearAllPoints()
		if tCC[tCC_Option.index].p then
			tCC_Move:SetPoint(tCC[tCC_Option.index].p,UIParent,tCC[tCC_Option.index].s,tCC[tCC_Option.index].x,tCC[tCC_Option.index].y)
		else
			tCC_Move:SetPoint("CENTER",UIParent,"CENTER",0,0)
		end
		tCC_Move:Show()
	end
end
