local IRF2 = InvenRaidFrames2
local Option = IRF2.optionFrame
local LBO = LibStub("LibBlueOption-1.0")
local SM = LibStub("LibSharedMedia-3.0")

local _G = _G
local pairs = _G.pairs
local ipairs = _G.ipairs
local unpack = _G.unpack

function Option:CreateFrameMenu(menu, parent)
	local statusBars = { "health", "mana", "heal", "resCastingBar", "castingBar" }
	menu.texture = LBO:CreateWidget("Media", parent, "바 텍스쳐", "바 텍스쳐를 설정합니다.", nil, nil, nil,
		function() return IRF2.db.layout.texture, "statusbar" end,
		function(v)
			IRF2.db.layout.texture = v
			local file, r, g, b = SM:Fetch("statusbar", v)
			for _, object in pairs(IRF2.objects) do
				for _, bar in pairs(statusBars) do
					if object[bar] then
						r, g, b = object[bar]:GetStatusBarColor()
						object[bar]:SetStatusBarTexture(file)
						object[bar]:SetStatusBarColor(r, g, b)
					end
				end
			end
		end
	)
	menu.texture:SetPoint("TOPLEFT", 5, -5)
	menu.scale = LBO:CreateWidget("Slider", parent, "크기", "프레임의 전체적인 크기를 조절합니다.", nil, nil, true,
		function()
			return IRF2.db.layout.scale * 100, 50, 150, 1, "%"
		end,
		function(v)
			IRF2.db.layout.scale = v / 100
			IRF2.anchor:SetScale(IRF2.db.layout.scale)
			for i = 0, #IRF2.group do
				IRF2.group[i]:SetScale(IRF2.db.layout.scale)
			end
			if IRF2.borderFrame then
				IRF2.borderFrame:SetScale(IRF2.db.layout.scale)
			end
		end
	)
	menu.scale:SetPoint("TOPRIGHT", -5, -5)
	menu.width = LBO:CreateWidget("Slider", parent, "너비", "프레임의 너비를 조절합니다.", nil, nil, true,
		function()
			return IRF2.db.layout.width, 32, 200, 1, "픽셀"
		end,
		function(v)
			IRF2.db.layout.width = v
			for _, object in pairs(IRF2.objects) do
				object:SetSafeAttribute("initial-width", v)
				object:SetWidth(v)
			end
			for i = 0, 8 do
				IRF2.group[i].partyTag:SetWidth(v)
			end
			IRF2:SetGroupPosition()
			IRF2:UpdateClampRectInsets()
			if IRF2.group.pet then
				IRF2:UpdatePetClampRectInsets()
			end
		end
	)
	menu.width:SetPoint("TOP", menu.texture, "BOTTOM", 0, -10)
	menu.height = LBO:CreateWidget("Slider", parent, "높이", "프레임의 높이를 조절합니다.", nil, nil, true,
		function()
			return IRF2.db.layout.height, 25, 70, 1, "픽셀"
		end,
		function(v)
			IRF2.db.layout.height = v
			for _, object in pairs(IRF2.objects) do
				object:SetSafeAttribute("initial-height", v)
				object:SetHeight(v)
				if object.health then
					object.health:ClearAllPoints()
					object.mana:ClearAllPoints()
					if IRF2.db.layout.manaBar == 0 then
						object.health:SetAllPoints(object)
						object.mana:SetPoint("TOPLEFT", object, "BOTTOMLEFT")
						object.mana:SetPoint("BOTTOMRIGHT", object, "BOTTOMRIGHT")
					elseif IRF2.db.layout.manaBar == 1 then
						object.health:SetPoint("TOPLEFT", object, "TOPLEFT")
						object.health:SetPoint("BOTTOMRIGHT", object, "TOPRIGHT")
						object.mana:SetAllPoints(object)
					else
						object.health:SetPoint("TOPLEFT", object, "TOPLEFT")
						object.health:SetPoint("BOTTOMRIGHT", object, "BOTTOMRIGHT", 0, IRF2.db.layout.height * IRF2.db.layout.manaBar)
						object.mana:SetPoint("TOPLEFT", object, "TOPLEFT", 0, -(IRF2.db.layout.height * (1 - IRF2.db.layout.manaBar) + 1))
						object.mana:SetPoint("BOTTOMRIGHT", object, "BOTTOMRIGHT")
					end
				end
			end
			for i = 0, 8 do
				IRF2.group[i].partyTag1:SetHeight(v)
			end
			IRF2:SetGroupPosition()
			IRF2:UpdateClampRectInsets()
			if IRF2.group.pet then
				IRF2:UpdatePetClampRectInsets()
			end
		end
	)
	menu.height:SetPoint("TOP", menu.scale, "BOTTOM", 0, -10)
	menu.offset = LBO:CreateWidget("Slider", parent, "간격", "각 플레이어 간의 간격을 조절합니다.", nil, nil, true,
		function()
			return IRF2.db.layout.offset, 0, 30, 1, "픽셀"
		end,
		function(v)
			IRF2.db.layout.offset = v
			IRF2:SetGroupPosition()
			if IRF2.group.pet then
				IRF2:SetPetGroupOrder()
			end
		end
	)
	menu.offset:SetPoint("TOP", menu.width, "BOTTOM", 0, -10)
	menu.highlightAlpha = LBO:CreateWidget("Slider", parent, "하이라이트 투명도", "프레임에 마우스를 올렸을때 나오는 하이라이트 텍스쳐의 투명도를 설정합니다. 0으로 설정하면 보이지 않습니다.", nil, nil, nil,
		function()
			return IRF2.db.highlightFrameAlpha * 100, 0, 100, 1, "%"
		end,
		function(v)
			IRF2.db.highlightFrameAlpha = v / 100
			IRF2.highlightFrame:SetAlpha(IRF2.db.highlightFrameAlpha)
		end
	)
	menu.highlightAlpha:SetPoint("TOP", menu.height, "BOTTOM", 0, -10)
	menu.color = LBO:CreateWidget("ColorPicker", parent, "배경 색상", "각 플레이어 프레임의 뒷 배경 색상 및 투명도를 설정합니다.", nil, nil, nil,
		function()
			return unpack(IRF2.db.layout.backdropColor)
		end,
		function(r, g, b, a)
			IRF2.db.layout.backdropColor[1], IRF2.db.layout.backdropColor[2], IRF2.db.layout.backdropColor[3], IRF2.db.layout.backdropColor[4] = r, g, b, a
			for _, object in pairs(IRF2.objects) do
				if object.initUnit then
					object:SetBackdropColor(r, g, b, a)
					if object.UpdateOutline then
						object:UpdateOutline()
					end
				end
			end
		end
	)
	menu.color:SetPoint("TOP", menu.offset, "BOTTOM", 0, -10)
end

function Option:CreateHealthBarMenu(menu, parent)
	menu.orientation = LBO:CreateWidget("DropDown", parent, "체력바 방향", "체력바의 진행 방향을 설정합니다.", nil, nil, nil,
		function()
			return IRF2.db.layout.healthOrientation, Option.dropdownTable["가로세로"]
		end,
		function(v)
			IRF2.db.layout.healthOrientation = v
			v = v == "세로" and "VERTICAL" or "HORIZONTAL"
			for _, object in pairs(IRF2.objects) do
				if object.health then
					object.health:SetOrientation(v)
				end
				if object.heal then
					object.heal:SetOrientation(v)
				end
			end
		end
	)
	menu.orientation:SetPoint("TOPLEFT", 5, -5)
	local function getUseClassColor() return IRF2.db.layout.classHealth end
	menu.classColor = LBO:CreateWidget("CheckBox", parent, "직업별 체력바 색상", "직업별 색상에 따라 체력바 색상을 변경합니다.", nil, nil, nil,
		getUseClassColor,
		function(v)
			IRF2.db.layout.classHealth = v
			IRF2:UpdateAllUnits()
			LBO:Refresh(parent)
		end
	)
	menu.classColor:SetPoint("TOPRIGHT", -5, -5)
	menu.color = LBO:CreateWidget("ColorPicker", parent, "체력바 색상", "각 플레이어의 체력바 색상을 설정합니다.", nil, getUseClassColor, nil,
		function()
			return unpack(IRF2.db.layout.healthColor)
		end,
		function(r, g, b)
			IRF2.db.layout.healthColor[1], IRF2.db.layout.healthColor[2], IRF2.db.layout.healthColor[3] = r, g, b
			IRF2:UpdateAllUnits()
		end
	)
	menu.color:SetPoint("TOP", menu.orientation, "BOTTOM", 0, -10)
	menu.offlineColor = LBO:CreateWidget("ColorPicker", parent, "오프라인 색상", "오프라인이거나 죽은 플레이어의 체력바 색상을 설정합니다.", nil, nil, nil,
		function()
			return unpack(IRF2.db.layout.offlineColor)
		end,
		function(r, g, b)
			IRF2.db.layout.offlineColor[1], IRF2.db.layout.offlineColor[2], IRF2.db.layout.offlineColor[3] = r, g, b
			IRF2:UpdateAllUnits()
		end
	)
	menu.offlineColor:SetPoint("TOP", menu.classColor, "BOTTOM", 0, -10)
	local displayType = { "남은 생명력", "손실 생명력" }
	menu.display = LBO:CreateWidget("DropDown", parent, "체력바 채움 방식(반전)", "체력바 채움 방식을 설정합니다. 남은 생명력으로 설정하면 만피일때 체력바가 가득차게 되고, 손실 생명력으로 설정하면 만피일때 체력바가 비게 됩니다. ", true, nil, nil,
		function()
			return IRF2.db.layout.healthDisplayType, displayType
		end,
		function(v)
			IRF2.db.layout.healthDisplayType = v
			IRF2:UpdateAllUnits()
		end
	)
	menu.display:SetPoint("TOP", menu.color, "BOTTOM", 0 ,0)
end

function Option:CreateManaBarMenu(menu, parent)
	menu.height = LBO:CreateWidget("Slider", parent, "마나바 비율", "각 플레이어 프레임 상에서 마나바의 비율을 설정합니다. 0%로 설정하면 마나바가 숨겨지며 100%로 설정하면 체력바가 숨겨집니다.", nil, nil, nil,
		function()
			return IRF2.db.layout.manaBar * 100, 0, 100, 1, "%"
		end,
		function(v)
			IRF2.db.layout.manaBar = v / 100
			for _, object in pairs(IRF2.objects) do
				if object.health then
					object.health:ClearAllPoints()
					object.mana:ClearAllPoints()
					if v == 0 then
						object.health:SetAllPoints(object)
						object.mana:SetPoint("TOPLEFT", object, "BOTTOMLEFT")
						object.mana:SetPoint("BOTTOMRIGHT", object, "BOTTOMRIGHT")
					elseif v == 1 then
						object.health:SetPoint("TOPLEFT", object, "TOPLEFT")
						object.health:SetPoint("BOTTOMRIGHT", object, "TOPRIGHT")
						object.mana:SetAllPoints(object)
					else
						object.health:SetPoint("TOPLEFT", object, "TOPLEFT")
						object.health:SetPoint("BOTTOMRIGHT", object, "BOTTOMRIGHT", 0, IRF2.db.layout.height * IRF2.db.layout.manaBar)
						object.mana:SetPoint("TOPLEFT", object, "TOPLEFT", 0, -(IRF2.db.layout.height * (1 - IRF2.db.layout.manaBar) + 1))
						object.mana:SetPoint("BOTTOMRIGHT", object, "BOTTOMRIGHT")
					end
				end
			end
		end
	)
	menu.height:SetPoint("TOPLEFT", 5, -5)
	local powerList = { "MANA", "RAGE", "ENERGY", "RUNIC_POWER", "FOCUS" }
	menu.reset = LBO:CreateWidget("Button", parent, "색상 초기화", "설정된 색상을 기본값으로 복원합니다.", nil, nil, nil,
		function()
			for i, power in pairs(powerList) do
				IRF2.db.powerColor[power][1] = PowerBarColor[power].r
				IRF2.db.powerColor[power][2] = PowerBarColor[power].g
				IRF2.db.powerColor[power][3] = PowerBarColor[power].b
			end
			IRF2:UpdateAllUnits()
			LBO:Refresh(parent)
		end
	)
	menu.reset:SetPoint("TOPRIGHT", -5, -5)
	local function getPowerColor(power)
		return unpack(IRF2.db.powerColor[power])
	end
	local function setPowerColor(r, g, b, power)
		IRF2.db.powerColor[power][1], IRF2.db.powerColor[power][2], IRF2.db.powerColor[power][3] = r, g, b
		IRF2:UpdateAllUnits()
	end
	for i, power in ipairs(powerList) do
		menu["power"..i] = LBO:CreateWidget("ColorPicker", parent, _G[power], _G[power].."의 색상을 변경합니다.", nil, nil, nil, getPowerColor, setPowerColor, power)
		if i == 1 then
			menu["power"..i]:SetPoint("TOP", menu.height, "BOTTOM", 0, -10)
		elseif i == 2 then
			menu["power"..i]:SetPoint("TOP", menu.reset, "BOTTOM", 0, -10)
		else
			menu["power"..i]:SetPoint("TOP", menu["power"..(i - 2)], "BOTTOM", 0, 0)
		end
	end
end

function Option:CreateNameMenu(menu, parent)
	menu.file = LBO:CreateWidget("Font", parent, "이름 글꼴 설정", "이름 글꼴을 변경합니다.", nil, nil, nil,
		function()
			return IRF2.db.font.file, IRF2.db.font.size, IRF2.db.font.attribute, IRF2.db.font.shadow
		end,
		function(file, size, attribute, shadow)
			IRF2.db.font.file, IRF2.db.font.size, IRF2.db.font.attribute, IRF2.db.font.shadow = file, size, attribute, shadow
			IRF2:SetFont(IRF2.tempText)
			for _, object in pairs(IRF2.objects) do
				if object.text then
					IRF2:SetFont(object.text)
					if object.UpdateText then
						object:UpdateText()
					end
				end
			end
		end
	)
	menu.file:SetPoint("TOPLEFT", 5, -5)
	local function getClassColorName()
		return IRF2.db.layout.className
	end
	menu.classColor = LBO:CreateWidget("CheckBox", parent, "직업별 이름 색상 사용", "이름 색상을 직업 색상으로 표시합니다.", nil, nil, nil,
		getClassColorName,
		function(v)
			IRF2.db.layout.className = v
			IRF2:UpdateAllUnits()
			LBO:Refresh(parent)
		end
	)
	menu.classColor:SetPoint("TOP", menu.file, "BOTTOM", 0, -10)
	menu.color = LBO:CreateWidget("ColorPicker", parent, "이름 색상", "이름 색상을 설정합니다. 직업별 색상 사용시 적용되지 않습니다.", nil, getClassColorName, nil,
		function()
			return unpack(IRF2.db.layout.nameColor)
		end,
		function(r, g, b)
			IRF2.db.layout.nameColor[1], IRF2.db.layout.nameColor[2], IRF2.db.layout.nameColor[3] = r, g, b
			IRF2.db.layout.className = v
			for _, object in pairs(IRF2.objects) do
				if object.text then
					if object.UpdateText then
						object:UpdateText()
					end
				end
			end
		end
	)
	menu.color:SetPoint("TOPRIGHT", -5, -60)
	menu.nameRv = LBO:CreateWidget("CheckBox", parent, "먼 사정거리 직업별 이름 색상 사용", "사정거리가 벗어난 플레이어의 이름 색상을 직업 색상으로 표시합니다.", nil, nil, nil,
		function()
			return IRF2.db.layout.nameRv
		end,
		function(v)
			IRF2.db.layout.nameRv = v
			IRF2:UpdateAllUnits()
		end
	)
	menu.nameRv:SetPoint("TOP", menu.classColor, "BOTTOM", 0, 0)
	menu.nameRvDeath = LBO:CreateWidget("CheckBox", parent, "죽은 플레이어 직업별 이름 색상 사용", "죽거나 유령인 플레이어의 이름 색상을 회색 대신 직업별 색상으로 표시합니다.", nil, nil, nil,
		function()
			return IRF2.db.layout.nameRvDeath
		end,
		function(v)
			IRF2.db.layout.nameRvDeath = v
			IRF2:UpdateAllUnits()
		end
	)
	menu.nameRvDeath:SetPoint("TOP", menu.nameRv, "BOTTOM", 0, 0)
end

function Option:CreateClassColorMenu(menu, parent)
	local classList = { "WARRIOR", "ROGUE", "PRIEST", "MAGE", "WARLOCK", "HUNTER", "DRUID", "SHAMAN", "PALADIN", "DEATHKNIGHT", "PET", "VEHICLE" }
	local classListLocale = { "전사", "도적", "사제", "마법사", "흑마법사", "사냥꾼", "드루이드", "주술사", "성기사", "죽음의 기사", "소환수", "탈것" }
	menu.reset = LBO:CreateWidget("Button", parent, "색상 초기화", "설정한 색상을 초기값으로 되돌립니다.", nil, nil, nil,
		function()
			for class, color in pairs(RAID_CLASS_COLORS) do
				if IRF2.db.classColor[class] then
					IRF2.db.classColor[class][1], IRF2.db.classColor[class][2], IRF2.db.classColor[class][3] = color.r, color.g, color.b
				end
			end
			IRF2.db.classColor.PET[1], IRF2.db.classColor.PET[2], IRF2.db.classColor.PET[3] = 0, 1, 0
			IRF2.db.classColor.VEHICLE[1], IRF2.db.classColor.VEHICLE[2], IRF2.db.classColor.VEHICLE[3] = 0, 0.4, 0
			IRF2:UpdateAllUnits()
			LBO:Refresh(parent)
		end
	)
	menu.reset:SetPoint("TOPLEFT", 5, 2)
	local function getClassColor(class)
		return unpack(IRF2.db.classColor[class])
	end
	local function setClassColor(r, g, b, class)
		IRF2.db.classColor[class][1], IRF2.db.classColor[class][2], IRF2.db.classColor[class][3] = r, g, b
		IRF2:UpdateAllUnits()
	end
	for i, class in ipairs(classList) do
		menu["color"..i] = LBO:CreateWidget("ColorPicker", parent, classListLocale[i], classListLocale[i].."의 색상을 변경합니다.", nil, nil, nil, getClassColor, setClassColor, class)
		if i == 1 then
			menu["color"..i]:SetPoint("TOPLEFT", 5, -35)
		elseif i == 2 then
			menu["color"..i]:SetPoint("TOPRIGHT", -5, -35)
		else
			menu["color"..i]:SetPoint("TOP", menu["color"..(i - 2)], "BOTTOM", 0, 0)
		end
	end
end

function Option:CreatePartyTagMenu(menu, parent)
	menu.use = LBO:CreateWidget("CheckBox", parent, "파티 이름표 보기", "공격대 각 파티의 이름표를 표시합니다.", nil,
		function()
			return IRF2.db.groupOrder.byClass or IRF2.db.groupOrder.byName
		end, true,
		function()
			return IRF2.db.partyTag
		end,
		function(v)
			IRF2.db.partyTag = v
			IRF2:SetGroupPosition()
			LBO:Refresh(parent)
		end
	)
	menu.use:SetPoint("TOPLEFT", 5, 5)
	local function disable()
		return IRF2.db.groupOrder.byClass or IRF2.db.groupOrder.byName or not IRF2.db.partyTag
	end
	local function get(group)
		return unpack(IRF2.db.partyTagColor[group])
	end
	local function set(r, g, b, group)
		IRF2.db.partyTagColor[group][1], IRF2.db.partyTagColor[group][2], IRF2.db.partyTagColor[group][3] = r, g, b
		IRF2.group[group].partyTag:SetBackdropColor(r, g, b)
		IRF2.group[group].partyTag1:SetBackdropColor(r, g, b)
	end
	for i = 0, 8 do
		if i == 0 then
			menu["color"..i] = LBO:CreateWidget("ColorPicker", parent, "내 파티 이름표 색상", "내 파티의 이름표 색상을 변경합니다.", nil, disable, nil, get, set, i)
			menu["color"..i]:SetPoint("TOPRIGHT", -5, 5)
		else
			menu["color"..i] = LBO:CreateWidget("ColorPicker", parent, "파티 "..i.." 이름표 색상", "파티 "..i.."의 이름표 색상을 변경합니다.", nil, disable, nil, get, set, i)
			if i == 1 then
				menu["color"..i]:SetPoint("TOP", menu.use, "BOTTOM", 0, 0)
			else
				menu["color"..i]:SetPoint("TOP", menu["color"..(i - 2)], "BOTTOM", 0, 0)
			end
		end
	end
end

function Option:CreateBorderMenu(menu, parent)
	menu.use = LBO:CreateWidget("CheckBox", parent, "배경 테두리 보기", "공격대 프레임 전체를 둘러싸는 테두리를 보입니다.", nil, nil, nil,
		function()
			return IRF2.db.border.show
		end,
		function(v)
			IRF2.db.border.show = v
			if IRF2.borderFrame then
				IRF2:UpdateBorder()
			end
			if IRF2.borderFramePet then
				IRF2:BorderPet()
			end
			LBO:Refresh(parent)
		end
	)
	menu.use:SetPoint("TOPLEFT", 5, 5)
	local function disable()
		return not IRF2.db.border.show
	end
	menu.reset = LBO:CreateWidget("Button", parent, "색상 초기화", "설정한 색상을 초기값으로 되돌립니다.", nil, disable, nil,
		function()
			IRF2.db.border.backdrop[1], IRF2.db.border.backdrop[2], IRF2.db.border.backdrop[3], IRF2.db.border.backdrop[4] = 0.29, 0.35, 0.37, 0.52
			IRF2.db.border.border[1], IRF2.db.border.border[2], IRF2.db.border.border[3], IRF2.db.border.border[4] = 0.58, 0.58, 0.58, 1
			if IRF2.borderFrame then
				IRF2.borderFrame:SetBackdropColor(unpack(IRF2.db.border.backdrop))
				IRF2.borderFrame:SetBackdropBorderColor(unpack(IRF2.db.border.border))
			end
			if IRF2.borderFramePet then
				IRF2.borderFramePet:SetBackdropColor(unpack(IRF2.db.border.backdrop))
				IRF2.borderFramePet:SetBackdropBorderColor(unpack(IRF2.db.border.border))
			end
			LBO:Refresh(parent)
		end
	)
	menu.reset:SetPoint("TOPRIGHT", -5, 5)
	menu.backdrop = LBO:CreateWidget("ColorPicker", parent, "배경 테두리 내부 색상", "공격대 프레임 전체를 둘러싸는 테두리의 내부 색상 및 투명도를 조절합니다.", nil, disable, nil,
		function()
			return unpack(IRF2.db.border.backdrop)
		end,
		function(r, g, b)
			IRF2.db.border.backdrop[1], IRF2.db.border.backdrop[2], IRF2.db.border.backdrop[3], IRF2.db.border.backdrop[4] = r, g, b, a
			if IRF2.borderFrame then
				IRF2.borderFrame:SetBackdropColor(r, g, b, a)
			end
			if IRF2.borderFramePet then
				IRF2.borderFramePet:SetBackdropColor(r, g, b, a)
			end
		end
	)
	menu.backdrop:SetPoint("TOP", menu.use, "BOTTOM", 0, 0)
	menu.border = LBO:CreateWidget("ColorPicker", parent, "배경 테두리 내부 색상", "공격대 프레임 전체를 둘러싸는 테두리의 내부 색상 및 투명도를 조절합니다.", nil, disable, nil,
		function()
			return unpack(IRF2.db.border.border)
		end,
		function(r, g, b, a)
			IRF2.db.border.border[1], IRF2.db.border.border[2], IRF2.db.border.border[3], IRF2.db.border.border[4] = r, g, b, a
			if IRF2.borderFrame then
				IRF2.borderFrame:SetBackdropBorderColor(r, g, b, a)
			end
			if IRF2.borderFramePet then
				IRF2.borderFramePet:SetBackdropBorderColor(r, g, b, a)
			end
		end
	)
	menu.border:SetPoint("TOP", menu.reset, "BOTTOM", 0, 0)
end

function Option:CreateDebuffColorMenu(menu, parent)
	menu.reset = LBO:CreateWidget("Button", parent, "색상 초기화", "설정한 색상을 초기값으로 되돌립니다.", nil, nil, nil,
		function()
			IRF2.db.debuffColor.Curse[1], IRF2.db.debuffColor.Curse[2], IRF2.db.debuffColor.Curse[3] = 0.6, 0, 1
			IRF2.db.debuffColor.Magic[1], IRF2.db.debuffColor.Magic[2], IRF2.db.debuffColor.Magic[3] = 1, 1, 1
			IRF2.db.debuffColor.Disease[1], IRF2.db.debuffColor.Disease[2], IRF2.db.debuffColor.Disease[3] = 0.6, 0.4, 0
			IRF2.db.debuffColor.Poison[1], IRF2.db.debuffColor.Poison[2], IRF2.db.debuffColor.Poison[3] = 0, 0.25, 0
			IRF2.db.debuffColor.Normal[1], IRF2.db.debuffColor.Normal[2], IRF2.db.debuffColor.Normal[3] = 0.31, 0.64, 0.44
			IRF2:UpdateAllUnits()
			LBO:Refresh(parent)
		end
	)
	menu.reset:SetPoint("TOPLEFT", 5, 2)
	local function get(debuff)
		return unpack(IRF2.db.debuffColor[debuff])
	end
	local function set(r, g, b, debuff)
		IRF2.db.debuffColor[debuff][1], IRF2.db.debuffColor[debuff][2], IRF2.db.debuffColor[debuff][3] = r, g, b
		IRF2:UpdateAllUnits()
	end
	for i, debuff in ipairs(Option.dropdownTable["디버프"]) do
		menu["color"..i] = LBO:CreateWidget("ColorPicker", parent, debuff, debuff.." 계열 디버프의 색상을 변경합니다.", nil, nil, nil, get, set, Option.dropdownTable["디버프영문"][i])
		if i == 1 then
			menu["color"..i]:SetPoint("TOPLEFT", 5, -35)
		elseif i == 2 then
			menu["color"..i]:SetPoint("TOPRIGHT", -5, -35)
		else
			menu["color"..i]:SetPoint("TOP", menu["color"..(i - 2)], "BOTTOM", 0, 0)
		end
	end
end