-- VisualComponents by Travis, modified for native visuals. 


local module = {}

module.panels = {}

local MapConstant = 40000
local VideoControl = require(script.VideoControl.Value)

local function mapScreen(center,screen)
	local dif = Instance.new("Attachment",center)
	dif.WorldPosition = screen.Position

	for i,v in pairs(screen.VisualScreen.Main:GetChildren()) do
		if v:IsA("ImageLabel") then
			v.Position = UDim2.new(0.5, dif.Position.X * MapConstant, 0.5, (dif.Position.Y - dif.Position.Z) * MapConstant )
		end
	end
	for i,v in pairs(screen.VisualScreen.SpriteVisual:GetChildren()) do
		if v:IsA("ImageLabel") then
			v.Position = UDim2.new(0.5, dif.Position.X * MapConstant, 0.5, (dif.Position.Y - dif.Position.Z) * MapConstant )
		end
	end


	screen.VisualScreen.CanvasSize = Vector2.new((screen.Size.X*MapConstant),(screen.Size.Y*MapConstant))
	dif:Destroy()
end

function module.Start(screensFolder)
	local center = screensFolder.CenterPart
	if screensFolder:FindFirstChild("Panels") then
		for i,v in pairs(screensFolder.Panels:GetChildren()) do
			local cloneFrame = script.Main:Clone()
			local cloneFrame1 = script.SpriteVisual:Clone()
			cloneFrame.Parent = v.VisualScreen
			cloneFrame1.Parent = v.VisualScreen
			mapScreen(center,v)
			table.insert(module.panels,v)
			v.Debug:Destroy()
		end
	end
	VideoControl.SpriteStart()
end


return module
