local self = InvenRaidFrames
local SM = LibStub("LibSharedMedia-3.0")
local layoutDB

function InvenRaidFrames:CreateMainFrame()
	if not self.vars.group.m then
		local m = CreateFrame("Frame", "InvenRaidFramesMain", UIParent)
		m:SetClampedToScreen(true)
		m:SetMovable(true)
		m:SetScale(self.db.profile.scale)
		local s = m:GetEffectiveScale()
		m:SetPoint(self.db.profile.pos[1], UIParent, self.db.profile.pos[1], self.db.profile.pos[2] / s, self.db.profile.pos[3] / s)
		m:SetHeight(self.db.profile.unitHeight)
		m:SetWidth(self.db.profile.unitWidth)
		local b = CreateFrame("Frame", nil, UIParent)
		b:SetPoint("TOPLEFT", m, "TOPLEFT", -4, 4)
		b:SetBackdrop({
			bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
			edgeFile = "Interface\\Addons\\InvenRaidFrames\\Texture\\Border",
			tile = true, tileSize = 16, edgeSize = 16,
			insets = { left = 2, right = 2, top = 2, bottom = 2 }
		})
		b:SetBackdropColor(unpack(self.db.profile.color.bg))
		b:SetBackdropBorderColor(unpack(self.db.profile.color.border))
		b:SetAlpha(self.db.profile.borderAlpha)
		--b:EnableMouse(true)
		b:SetMovable(true)
		b:RegisterForDrag("LeftButton")
		b:SetScript("OnDragStart", self.FrameOnDragStart)
		b:SetScript("OnDragStop", self.FrameOnDragStop)
		m.border = b
		m.border:SetScale(self.db.profile.scale)
		--m:SetScript("OnShow", function() m.border:Show() end)
		m:SetScript("OnHide", function() m.border:Hide() end)
		m:Show()
		self.vars.group.m = m
		local hlm = CreateFrame("Frame", nil, UIParent)
		local hl = hlm:CreateTexture(nil, "ADD")
		hl:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
		hl:SetBlendMode("ADD")
		hl:SetAllPoints(hlm)
		hlm:SetToplevel(true)
		hlm:SetAlpha(self.db.profile.moalpha)
		hlm:Hide()
		self.highlightFrame = hlm
		return m
	end
	return self.vars.group.m
end

function IRF_GroupInitialConfigFunction(frame)
	frame:SetAttribute("initial-width", self.db.profile.unitWidth)
	frame:SetAttribute("initial-height", self.db.profile.unitHeight)
end

function InvenRaidFrames:CreateGroup(index)
	if not self.vars.group[index] then
		local f = CreateFrame("Frame", "InvenRaidFramesGroup"..index, self.vars.group.m, (index == 0) and "SecurePartyHeaderTemplate" or "SecureRaidGroupHeaderTemplate")
		f:SetID(index)
		f.moved = false
		f.SetManyAttribute = self.SetManyAttribute
		f.SetHeaderAttribute = self.SetHeaderAttribute
		f:SetWidth(self.db.profile.unitWidth)
		f:SetHeight(self.db.profile.unitHeight)
		f:SetMovable(true)
		f:SetAttribute("template", "InvenRaidFramesSecureTemplate")
		f.initialConfigFunction = IRF_GroupInitialConfigFunction
		f:SetHeaderAttribute()
		self.vars.group[index] = f
		self:CreateTag(index)
	end
	return self.vars.group[index]
end

function InvenRaidFrames:SetManyAttribute(ab)
	for i = 1, #(ab), 2 do
		local p, v = ab[i], ab[i + 1]
		v = v ~= false and v or nil
		if self:GetAttribute(p) ~= v then
			self:SetAttribute(p, v)
		end
	end
end

function InvenRaidFrames:CreateTag(index)
	if not self.vars.tag[index] then
		local tag = {}
		for i = 1, 2 do
			local t = CreateFrame("Frame", nil, self.vars.group[index])
			t:SetWidth(i == 1 and (self.db.profile.unitWidth - 4) or 12)
			t:SetHeight(i == 1 and 12 or (self.db.profile.unitHeight - 4))
			t:EnableMouse(true)
			t:RegisterForDrag("LeftButton")
			t:SetMovable(true)
			t:SetScript("OnDragStart", self.FrameOnDragStart)
			t:SetScript("OnDragStop", self.FrameOnDragStop)
			t:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16 })
			t.text = t:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
			t.text:SetPoint("CENTER", t, "CENTER")
			t.text:SetTextColor(1, 1, 1, 1)
			if index == 0 then
				t:SetBackdropColor(unpack(self.db.profile.color.myparty))
			else
				t:SetBackdropColor(0, 0, 0)
			end
			tag[i] = t
		end
		tag[1].text:SetText(index == 0 and "내 파티" or ("파티 "..index))
		tag[1]:SetPoint("BOTTOM", self.vars.group[index], "TOP")
		tag[1]:Hide()
		self.vars.tag[index] = tag[1]
		tag[2].text:SetText(index == 0 and "M" or index)
		tag[2]:SetPoint("RIGHT", self.vars.group[index], "LEFT")
		tag[2]:Hide()
		self.vars.tag2[index] = tag[2]
	end
end

function InvenRaidFrames:UpdateGroupAttribute()
	self:RunLeaveCombat("UpdateGroupAttribute", self, "SetGroupAttribute")
end

function InvenRaidFrames:UpdateGroupSetPoint()
	self:RunLeaveCombat("UpdateGroupSetPoint", self, "GroupSetPoint")
end

function InvenRaidFrames:SetHeaderAttribute()
	local index = self:GetID()
	if InvenRaidFrames.db.profile.ordertype == "파티" then
		if index == 0 then
			self:SetManyAttribute({
				"showSolo", true,
				"showPlayer", true,
				"showParty", true,
				"point", InvenRaidFrames.db.profile.memberorder == "가로" and "LEFT" or "TOP",
				"maxColumns", false,
				"unitsPerColumn", false,
				"columnAnchorPoint", false,
				"xOffset", InvenRaidFrames.db.profile.offset,
				"yOffset", -InvenRaidFrames.db.profile.offset,
				"columnSpacing", InvenRaidFrames.db.profile.offset,
			})
		else
			self:SetManyAttribute({
				"groupFilter", ""..index,
				"groupingOrder", ""..index,
				"groupBy", "GROUP",
				"point", InvenRaidFrames.db.profile.memberorder == "가로" and "LEFT" or "TOP",
				"maxColumns", false,
				"unitsPerColumn", false,
				"columnAnchorPoint", false,
				"xOffset", InvenRaidFrames.db.profile.offset,
				"yOffset", -InvenRaidFrames.db.profile.offset,
				"columnSpacing", InvenRaidFrames.db.profile.offset,
			})
		end
		InvenRaidFrames:PreCreateUnitFrame(index, 5)
	elseif InvenRaidFrames.db.profile.memberorder2 == "가로" or InvenRaidFrames.db.profile.memberorder2 == "세로" then
		if index == 0 then
			self:SetManyAttribute({
				"showSolo", true,
				"showPlayer", true,
				"showParty", true,
				"point", InvenRaidFrames.db.profile.memberorder2 == "가로" and "LEFT" or "TOP",
				"maxColumns", false,
				"unitsPerColumn", false,
				"columnAnchorPoint", false,
				"xOffset", InvenRaidFrames.db.profile.offset,
				"yOffset", -InvenRaidFrames.db.profile.offset,
				"columnSpacing", InvenRaidFrames.db.profile.offset,
			})
			InvenRaidFrames:PreCreateUnitFrame(index, 5)
		elseif index == 1 then
			self:SetManyAttribute({
				"groupFilter", InvenRaidFrames.db.profile.classorder,
				"groupingOrder", InvenRaidFrames.db.profile.classorder,
				"groupBy", "CLASS",
				"point", InvenRaidFrames.db.profile.memberorder2 == "가로" and "LEFT" or "TOP",
				"columnAnchorPoint", InvenRaidFrames.db.profile.memberorder2 == "가로" and "TOP" or "LEFT",
				"maxColumns", 25,
				"unitsPerColumn", InvenRaidFrames.db.profile.membernum,
				"xOffset", InvenRaidFrames.db.profile.offset,
				"yOffset", -InvenRaidFrames.db.profile.offset,
				"columnSpacing", InvenRaidFrames.db.profile.offset,
			})
			InvenRaidFrames:PreCreateUnitFrame(index, 40)
		else
			self:SetManyAttribute({
				"groupFilter", "9",
				"groupingOrder", "9",
				"maxColumns", false,
				"unitsPerColumn", false,
				"columnAnchorPoint", false,
			})
		end
	else
		local cs = { strsplit(",", InvenRaidFrames.db.profile.classorder) }
		local c = cs[index] or "9"
		if index == 0 then
			self:SetManyAttribute({
				"showSolo", true,
				"showPlayer", true,
				"showParty", true,
				"point", InvenRaidFrames.db.profile.memberorder2 == "직업 단위 가로" and "TOP" or "LEFT",
				"maxColumns", false,
				"unitsPerColumn", false,
				"columnAnchorPoint", false,
				"xOffset", InvenRaidFrames.db.profile.offset,
				"yOffset", -InvenRaidFrames.db.profile.offset,
				"columnSpacing", InvenRaidFrames.db.profile.offset,
			})
			InvenRaidFrames:PreCreateUnitFrame(index, 5)
		else
			self:SetManyAttribute({
				"groupFilter", c,
				"groupingOrder", c,
				"groupBy", "CLASS",
				"point", InvenRaidFrames.db.profile.memberorder2 == "직업 단위 가로" and "TOP" or "LEFT",
				"maxColumns", false,
				"unitsPerColumn", false,
				"columnAnchorPoint", false,
				"xOffset", InvenRaidFrames.db.profile.offset,
				"yOffset", -InvenRaidFrames.db.profile.offset,
				"columnSpacing", InvenRaidFrames.db.profile.offset,
			})
			InvenRaidFrames:PreCreateUnitFrame(index, 15)
		end
	end
end

do

function InvenRaidFrames:SetGroupAttribute()
	for i = 0, 10 do
		self.vars.group[i]:SetHeaderAttribute()
	end
	self:GroupSetPoint()
end

function InvenRaidFrames:GroupSetPoint()
	for i = 0, 10 do
		if not self.vars.group[i] then return end
	end
	local db = self.db.profile
	local start = self:ShownPartyFrame() and 0 or 1
	local last = ceil(tonumber(strmatch(db.showGroup, "(%d+)") or db.maxmember) / 5)
	if self:ShownPartyFrame() then
		self.vars.group[0]:Show()
	else
		self.vars.group[0]:Hide()
	end
	if db.ordertype == "파티" then
		local tox, toy = 0, 0
		if db.tag then
			if db.memberorder == "가로" then
				tox, toy = 12, 0
			else
				tox, toy = 0, 12
			end
		end
		local line = db.groupnum
		local index = 0
		local list = {}
		if db.hidetemp then
			if db.grouporder == "세로" then
				for i = 0, 10 do
					local f = self.vars.group[i]
					if i < start or i > last then
						f:Hide()
					else
						index = index + 1
						list[index] = f
						if f.moved then
							f:ClearAllPoints()
						end
						if i == start then
							f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", tox, -toy)
						elseif mod(index, line) == 1 then
							f:SetPoint("TOPLEFT", list[index - line], "TOPRIGHT", db.offset + tox, 0)
						elseif db.memberorder == "가로" and index > line then
							f:SetPoint("TOPLEFT", list[index - line], "TOPRIGHT", db.offset + tox, -toy)
						else
							f:SetPoint("TOPLEFT", list[index - 1], "BOTTOMLEFT", 0, -db.offset - toy)
						end
						f.moved = true
						f:Show()
					end
				end
			else
				for i = 0, 10 do
					local f = self.vars.group[i]
					if i < start or i > last then
						f:Hide()
					else
						index = index + 1
						list[index] = f
						if f.moved then
							f:ClearAllPoints()
						end
						if i == start then
							f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", tox, -toy)
						elseif mod(index, line) == 1 then
							f:SetPoint("TOPLEFT", list[index - line], "BOTTOMLEFT", 0, -db.offset - toy)
						elseif index > line then
							if db.memberorder == "세로" then
								f:SetPoint("TOPLEFT", list[index - line], "BOTTOMLEFT", tox, -db.offset - toy)
							else
								f:SetPoint("TOPLEFT", list[index - 1], "TOPRIGHT", db.offset + tox, -toy)
							end
						else
							f:SetPoint("TOPLEFT", list[index - 1], "TOPRIGHT", db.offset + tox, 0)
						end
						f.moved = true
						f:Show()
					end
				end
			end
		elseif db.grouporder == "세로" then
			for i = 0, 10 do
				local f = self.vars.group[i]
				if i < start or i > last then
					f:Hide()
				else
					local member = db.hidetemp and self.vars.party[i] or 5
					index = index + 1
					list[index] = f
					if f.moved then
						f:ClearAllPoints()
					end
					if i == start then
						f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", tox, -toy)
					elseif db.memberorder == "세로" then
						if mod(index, line) == 1 then
							f:SetPoint("TOPLEFT", list[index - line], "TOPRIGHT", db.offset, 0)
						else
							f:SetPoint("TOPLEFT", list[index - 1], "TOPLEFT", 0, -(db.unitHeight + db.offset) * 5 - toy)
						end
					else
						if index > line then
							f:SetPoint("TOPLEFT", list[index - line], "TOPLEFT", (db.unitWidth + db.offset) * 5 + tox, 0)
						else
							f:SetPoint("TOPLEFT", list[index - 1], "BOTTOMLEFT", 0, -db.offset)
						end
					end
					f.moved = true
					f:Show()
				end
			end
		else
			for i = 0, 10 do
				local f = self.vars.group[i]
				if i < start or i > last then
					f:Hide()
				else
					index = index + 1
					list[index] = f
					if f.moved then
						f:ClearAllPoints()
					end
					if i == start then
						f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", tox, -toy)
					elseif db.memberorder == "세로" then
						if line == 1 then
							f:SetPoint("TOPLEFT", list[index - 1], "TOPLEFT", 0, -(db.unitHeight + db.offset) * 5 - toy)
						elseif mod(index, line) == 1 then
							f:SetPoint("TOPLEFT", list[index - line], "TOPLEFT", 0, -(db.unitHeight + db.offset) * 5 - toy)
						else
							f:SetPoint("TOPLEFT", list[index - 1], "TOPRIGHT", db.offset, 0)
						end
					else
						if mod(index, line) == 1 then
							f:SetPoint("TOPLEFT", list[index - line], "BOTTOMLEFT", 0, -db.offset)
						elseif index > line then
							f:SetPoint("TOPLEFT", list[index - line], "BOTTOMLEFT", 0, -db.offset)
						else
							f:SetPoint("TOPLEFT", list[index - 1], "TOPLEFT", (db.unitWidth + db.offset) * 5 + tox, 0)
						end
					end
					f.moved = true
					f:Show()
				end
			end
		end
	elseif db.memberorder2 == "직업 단위 가로" then
		for i = 0, 10 do
			local f = self.vars.group[i]
			if i < start then
				f:Hide()
			else
				if f.moved then
					f:ClearAllPoints()
				end
				if i == start then
					f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", 0, 0)
				else
					f:SetPoint("TOPLEFT", self.vars.group[i - 1], "TOPRIGHT", db.offset, 0)
				end
				f.moved = true
				f:Show()
			end
		end
	elseif db.memberorder2 == "직업 단위 세로" then
		for i = 0, 10 do
			local f = self.vars.group[i]
			if i < start then
				f:Hide()
			else
				if f.moved then
					f:ClearAllPoints()
				end
				if i == start then
					f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", 0, 0)
				else
					f:SetPoint("TOPLEFT", self.vars.group[i - 1], "BOTTOMLEFT", 0, -db.offset)
				end
				f.moved = true
				f:Show()
			end
		end
	else
		if start == 0 then
			self.vars.group[0]:Show()
			if self.vars.group[0].moved then
				self.vars.group[0]:ClearAllPoints()
			end
			self.vars.group[0]:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", 0, 0)
			self.vars.group[0].moved = true
		end
		if db.memberorder2 == "세로" then
			for i = 1, 10 do
				local f = self.vars.group[i]
				if i == 1 then
					if f.moved then
						f:ClearAllPoints()
					end
					if start == 0 then
						f:SetPoint("TOPLEFT", self.vars.group[0], "TOPRIGHT", db.offset, 0)
					else
						f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", 0, 0)
					end
					f.moved = true
					f:Show()
				else
					f:Hide()
				end
			end
		else
			for i = 1, 10 do
				local f = self.vars.group[i]
				if i == 1 then
					if f.moved then
						f:ClearAllPoints()
					end
					if start == 0 then
						f:SetPoint("TOPLEFT", self.vars.group[0], "BOTTOMLEFT", 0, -db.offset)
					else
						f:SetPoint("TOPLEFT", self.vars.group.m, "TOPLEFT", 0, 0)
					end
					f.moved = true
					f:Show()
				else
					f:Hide()
				end
			end
		end
	end
	self.vars.range = {}
	self:CallbackTimer("UpdateBorder", 0.1)
end

function InvenRaidFrames:UpdateBorder()
	if self.db.profile.showbg and self.vars.showMainFrame then
		local pp = false
		local x, y = 0, 10000
		local topx, topy = self.vars.group.m:GetLeft(), self.vars.group.m:GetTop()
		if topx and topy then
			for unit, frame in pairs(self.vars.unit) do
				if frame:IsVisible() and not self.vars.pet[unit] then
					local r, b = frame:GetRight(), frame:GetBottom()
					if r and b then
						pp = true
						x = max(x, r)
						y = min(y, b)
					end
				end
			end
			if pp and self.db.profile.ordertype == "파티" and self.db.profile.tag then
				local tag = self.vars["tag"..(self.db.profile.memberorder == "세로" and "" or "2")]
				local start = self:ShownPartyFrame() and 0 or 1
				local last = 0
				for i = 1, self.vars.member.raid do
					last = max(select(3, GetRaidRosterInfo(i)), last)
				end
				for i = start, last do
					local t = tag[i]
					if t:IsVisible() then
						local r, b = t:GetRight(), t:GetBottom()
						if r and b then
							pp = true
							x = max(x, r)
							y = min(y, b)
						end
					end
				end
			end
			if pp then
				self.vars.group.m.border:Show()
				local m = self.vars.group.m.border
				m:SetWidth(x - topx + 8)
				m:SetHeight(topy - y + 8)
			else
				self.vars.group.m.border:Hide()
			end
		else
			self.vars.group.m.border:Hide()
		end
	else
		self.vars.group.m.border:Hide()
	end
	self:SendMessage("IvenRaidFrames_UpdateBorder")
end

function InvenRaidFrames:TagUpdate()
	if InCombatLockdown() then
		self:RunLeaveCombat("UpdateGroupTag", self, "TagUpdate")
		if self.db.profile.ordertype == "파티" and self.db.profile.tag then
			for i = 0, 8 do
				if i == 0 or i == self.vars.playerGroup then
					self.vars.tag[i]:SetBackdropColor(unpack(self.db.profile.color.myparty))
					self.vars.tag2[i]:SetBackdropColor(unpack(self.db.profile.color.myparty))
				else
					self.vars.tag[i]:SetBackdropColor(0, 0, 0)
					self.vars.tag2[i]:SetBackdropColor(0, 0, 0)
				end
			end
		end
	else
		if self.db.profile.ordertype == "파티" and self.db.profile.tag then
			local start, last = self:ShownPartyFrame() and 0 or 1, 0
			for i = 1, self.vars.member.raid do
				last = max(select(3, GetRaidRosterInfo(i)), last)
			end
			if self.db.profile.memberorder == "세로" then
				for i = 0, 8 do
					local t = self.vars.tag[i]
					if i >= start and i <= last then
						t:Show()
						if i == 0 or i == self.vars.playerGroup then
							t:SetBackdropColor(unpack(self.db.profile.color.myparty))
						else
							t:SetBackdropColor(0, 0, 0)
						end
					else
						t:Hide()
					end
					self.vars.tag2[i]:Hide()
				end
			else
				for i = 0, 8 do
					local t = self.vars.tag2[i]
					if i >= start and i <= last then
						t:Show()
						if i == 0 or i == self.vars.playerGroup then
							t:SetBackdropColor(unpack(self.db.profile.color.myparty))
						else
							t:SetBackdropColor(0, 0, 0)
						end
					else
						t:Hide()
					end
					self.vars.tag[i]:Hide()
				end
			end
		else
			for i = 0, 8 do
				self.vars.tag[i]:Hide()
				self.vars.tag2[i]:Hide()
			end
		end
	end
end

function InvenRaidFrames:ShownPartyFrame()
	local u = self.db.profile.use
	local p = self.db.profile.useparty
	if u == "항상" then
		if self.vars.member.raid == 0 then				-- 공격대 아닐때
			return true
		elseif self.vars.member.raid > 0 and p then			-- 공격대 참여 + 자기 파티
			return true
		end
	elseif u == "파티" then
		if self.vars.member.raid == 0 and self.vars.member.party > 0 then	-- 파티 참여시
			return true
		elseif self.vars.member.raid > 0 and p then			-- 공격대 참여 + 자기 파티
			return true
		end
	elseif u == "공격대" and self.vars.member.raid > 0 and p then	-- 공격대 참여 + 자기 파티
		return true
	end
	return false
end

function InvenRaidFrames:HasMember(index)
	local f = self.vars.group[index or 0]
	if f then
		local c = f:GetAttribute("child1")
		if c and c:IsVisible() then
			return true
		end
	end
	return false
end

end

function InvenRaidFrames:GetNumGroupMembers(index, button)
	local f = self.vars.group[index or 0]
	if button and f then
		for i = 1, 40 do
			local c = f:GetAttribute("child"..i)
			if not(c and c.unit and self.vars.unit[c.unit]) then
				return i - 1
			end
		end
	end
	return self.vars.party[index or 0]
end

function InvenRaidFrames:SavePosition()
	for i = 1, 2 do
		if i == 2 and not self:IsEnableModule("Pet") then
			return
		end
		local f = i == 1 and self.vars.group.m or IRF_Pet.vars.main
		local s = f:GetEffectiveScale()
		local uiScale = UIParent:GetEffectiveScale()
		local anchor = self.db.profile.anchor
		local x, y
		if anchor == "CENTER" then
			x = (f:GetLeft() + f:GetWidth() / 2) * s - UIParent:GetWidth() / 2 * uiScale
			y = (f:GetTop() - f:GetHeight() / 2) * s - UIParent:GetHeight() / 2 * uiScale
		elseif anchor == "TOP" then
			x = (f:GetLeft() + f:GetWidth() / 2) * s - UIParent:GetWidth() / 2 * uiScale
			y = f:GetTop() * s - UIParent:GetHeight() * uiScale
		elseif anchor == "LEFT" then
			x = f:GetLeft() * s
			y = (f:GetTop() - f:GetHeight() / 2) * s - UIParent:GetHeight() / 2 * uiScale
		elseif anchor == "RIGHT" then
			x = f:GetRight() * s - UIParent:GetWidth() * uiScale
			y = (f:GetTop() - f:GetHeight() / 2) * s - UIParent:GetHeight() / 2 * uiScale
		elseif anchor == "BOTTOM" then
			x = (f:GetLeft() + f:GetWidth() / 2) * s - UIParent:GetWidth() / 2 * uiScale
			y = f:GetBottom() * s
		elseif anchor == "TOPLEFT" then
			x = f:GetLeft() * s
			y = f:GetTop() * s - UIParent:GetHeight() * uiScale
		elseif anchor == "TOPRIGHT" then
			x = f:GetRight() * s - UIParent:GetWidth() * uiScale
			y = f:GetTop() * s - UIParent:GetHeight() * uiScale
		elseif anchor == "BOTTOMLEFT" then
			x = f:GetLeft() * s
			y = f:GetBottom() * s
		elseif anchor == "BOTTOMRIGHT" then
			x = f:GetRight() * s - UIParent:GetWidth() * uiScale
			y = f:GetBottom() * s
		end
		if x and y and s then
			self.db.profile[i == 1 and "pos" or "pospet"] = { anchor, x, y }
		end
	end
end