local R=game:GetService("\087\111\114\107\115\112\097\099\101")local s=game:GetService("\080\108\097\121\101\114\115")local t=game:GetService("\076\105\103\104\116\105\110\103")local W=require(script.Parent:WaitForChild("\066\097\115\101\084\101\115\116"))local V=W:Extend()V:SetClassName("\083\099\114\101\101\110\067\111\118\101\114\115\084\101\115\116")function V.__new(W)W:InitializeSuper()W.Name="\083\099\114\101\101\110 \067\111\118\101\114\115"W.Icon="\078\079\078\069"W.Status="\078\111\116 \068\101\116\101\099\116\101\100"W.ProblemText="\067\111\118\101\114\105\110\103 \116\104\101 \115\099\114\101\101\110 \105\115\110\'\116 \101\102\102\101\099\116\105\118\101 \102\111\114 \086\082 \117\115\101\114\115 \098\101\099\097\117\115\101 \083\099\114\101\101\110\071\117\105\115 \097\112\112\101\097\114 \105\110 \102\114\111\110\116 \111\102 \116\104\101 \117\115\101\114\046 \084\104\101\121 \106\117\115\116 \097\112\112\101\097\114 \097\115 \097 \114\097\110\100\111\109 \115\113\117\097\114\101 \105\110 \102\114\111\110\116\046"W.SolutionText="\082\101\109\111\118\101 \116\104\101 \109\097\105\110 \099\111\118\101\114 \097\110\100 \117\115\101 \101\105\116\104\101\114 \097 \066\108\117\114\069\102\102\101\099\116 \111\114 \067\111\108\111\114\067\111\114\114\101\099\116\105\111\110\069\102\102\101\099\116 \116\111 \109\097\115\107 \116\104\101 \099\111\110\116\101\110\116\046"W.Events={}local V=s.LocalPlayer:WaitForChild("\080\108\097\121\101\114\071\117\105")V.DescendantRemoving:Connect(function(R)if not W.Events[R]then return end for R,s in pairs(W.Events[R])do s:Disconnect()end W.Events[R]=nil end)V.DescendantAdded:Connect(function(R)if W.Events[R]then return end W:ConnectScreenGui(R)end)for R,s in pairs(V:GetDescendants())do W:ConnectScreenGui(s)end;(W:GetPropertyChangedSignal("\073\110\102\111\086\105\101\119")):Connect(function()if W.InfoView=="\080\082\079\066\076\069\077"or W.InfoView=="\083\079\076\085\084\073\079\078"then if not W.DemoPart then local s=Instance.new("\080\097\114\116")s.Transparency=1 s.CanCollide=false s.Anchored=true s.CFrame=(R.CurrentCamera.CFrame*CFrame.new(0,0,-15))*CFrame.Angles(0,math.pi,0)s.Size=Vector3.new(10,10,0)s.Parent=R.CurrentCamera W.DemoPart=s local t=Instance.new("\083\117\114\102\097\099\101\071\117\105")t.CanvasSize=Vector2.new(500,500)t.Adornee=s t.AlwaysOnTop=true t.Parent=s local V=Instance.new("\070\114\097\109\101")V.BackgroundColor3=Color3.new(0,0,0)V.BackgroundTransparency=0 V.BorderSizePixel=0 V.Size=UDim2.new(1,0,1,0)V.Parent=t W.DemoCover=V local H=Instance.new("\073\109\097\103\101\076\097\098\101\108")H.BackgroundTransparency=1 H.Size=UDim2.new(.5,0,.5,0)H.Position=UDim2.new(.25,0,.25,0)H.Image="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\053\050\050\049\048\050\050\057\053\054"H.Parent=t end W.DemoCover.Visible=W.InfoView=="\080\082\079\066\076\069\077"else if W.DemoPart then W.DemoPart:Destroy()W.DemoPart=nil end end if W.InfoView=="\083\079\076\085\084\073\079\078"then if not W.DemoBlur then local R=Instance.new("\066\108\117\114\069\102\102\101\099\116")R.Parent=t W.DemoBlur=R end else if W.DemoBlur then W.DemoBlur:Destroy()W.DemoBlur=nil end end end)end function V.ConnectScreenGui(s,R)if not R:IsA("\083\099\114\101\101\110\071\117\105")then return end local function t()if s.Icon=="\073\078\070\079"then return end local t=R.AbsoluteSize for R,W in pairs(R:GetDescendants())do if W:IsA("\071\117\105\079\098\106\101\099\116")then local R,V=W.AbsoluteSize,W.AbsolutePosition if W.BackgroundTransparency<1 and(V.X<=0 and(V.Y<=0 and(V.X+R.X>=t.X and V.Y+R.Y>=t.Y)))then s.Icon="\073\078\070\079"s.Status="\080\114\111\098\108\101\109 \068\101\116\101\099\116\101\100"break end end end end s.Events[R]={}table.insert(s.Events[R],R.DescendantAdded:Connect(function(W)if not W:IsA("\071\117\105\079\098\106\101\099\116")then return end table.insert(s.Events[R],(W:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\083\105\122\101")):Connect(t))t()end))t()end return V
--[[
TheNexusAvenger

Test for ScreenGuis covering the screen.
--]]

local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local Lighting = game:GetService("Lighting")

local BaseTest = require(script.Parent:WaitForChild("BaseTest"))

local ScreenCoversTest = BaseTest:Extend()
ScreenCoversTest:SetClassName("ScreenCoversTest")



--[[
Creates the test.
--]]
function ScreenCoversTest:__new()
    self:InitializeSuper()

    --Set up the initial state.
    self.Name = "Screen Covers"
    self.Icon = "NONE"
    self.Status = "Not Detected"
    self.ProblemText = "Covering the screen isn't effective for VR users because ScreenGuis appear in front of the user. They just appear as a random square in front."
    self.SolutionText = "Remove the main cover and use either a BlurEffect or ColorCorrectionEffect to mask the content."
    self.Events = {}

    --Connect ScreenGuis in PlayerGui.
    local PlayerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
    PlayerGui.DescendantRemoving:Connect(function(Ins)
        if not self.Events[Ins] then return end
        for _,Event in pairs(self.Events[Ins]) do
            Event:Disconnect()
        end
        self.Events[Ins] = nil
    end)
    PlayerGui.DescendantAdded:Connect(function(Ins)
        if self.Events[Ins] then return end
        self:ConnectScreenGui(Ins)
    end)
    for _,Ins in pairs(PlayerGui:GetDescendants()) do
        self:ConnectScreenGui(Ins)
    end

    --Connect showing the demo.
    self:GetPropertyChangedSignal("InfoView"):Connect(function()
        if self.InfoView == "PROBLEM" or self.InfoView == "SOLUTION" then
            if not self.DemoPart then
                local DemoPart = Instance.new("Part")
                DemoPart.Transparency = 1
                DemoPart.CanCollide = false
                DemoPart.Anchored = true
                DemoPart.CFrame = Workspace.CurrentCamera.CFrame * CFrame.new(0,0,-15) * CFrame.Angles(0,math.pi,0)
                DemoPart.Size = Vector3.new(10,10,0)
                DemoPart.Parent = Workspace.CurrentCamera
                self.DemoPart = DemoPart

                local DemoSurfaceGui = Instance.new("SurfaceGui")
                DemoSurfaceGui.CanvasSize = Vector2.new(500,500)
                DemoSurfaceGui.Adornee = DemoPart
                DemoSurfaceGui.AlwaysOnTop = true
                DemoSurfaceGui.Parent = DemoPart

                local DemoCover = Instance.new("Frame")
                DemoCover.BackgroundColor3 = Color3.new(0,0,0)
                DemoCover.BackgroundTransparency = 0
                DemoCover.BorderSizePixel = 0
                DemoCover.Size = UDim2.new(1,0,1,0)
                DemoCover.Parent = DemoSurfaceGui
                self.DemoCover = DemoCover

                local DemoLogo = Instance.new("ImageLabel")
                DemoLogo.BackgroundTransparency = 1
                DemoLogo.Size = UDim2.new(0.5,0,0.5,0)
                DemoLogo.Position = UDim2.new(0.25,0,0.25,0)
                DemoLogo.Image = "http://www.roblox.com/asset/?id=5221022956"
                DemoLogo.Parent = DemoSurfaceGui
            end
            self.DemoCover.Visible = (self.InfoView == "PROBLEM")
        else
            if self.DemoPart then
                self.DemoPart:Destroy()
                self.DemoPart = nil
            end
        end

        if self.InfoView == "SOLUTION" then
            if not self.DemoBlur then
                local DemoBlur = Instance.new("BlurEffect")
                DemoBlur.Parent = Lighting
                self.DemoBlur = DemoBlur
            end
        else
            if self.DemoBlur then
                self.DemoBlur:Destroy()
                self.DemoBlur = nil
            end
        end
    end)
end

--[[
Connects a ScreenGui.
--]]
function ScreenCoversTest:ConnectScreenGui(ScreenGui)
    if not ScreenGui:IsA("ScreenGui") then return end

    --[[
    Checks the ScreenGui.
    --]]
    local function CheckScreenGui()
        --Return if the state is already set.
        if self.Icon == "INFO" then return end

        --Check if a frame covers the screen and set the state if one does.
        local AbsoluteSize = ScreenGui.AbsoluteSize
        for _,Frame in pairs(ScreenGui:GetDescendants()) do
            if Frame:IsA("GuiObject") then
                local FrameAbsoluteSize,FrameAbsolutePosition = Frame.AbsoluteSize,Frame.AbsolutePosition
                if Frame.BackgroundTransparency < 1 and FrameAbsolutePosition.X <= 0 and FrameAbsolutePosition.Y <= 0 and FrameAbsolutePosition.X + FrameAbsoluteSize.X >= AbsoluteSize.X and FrameAbsolutePosition.Y + FrameAbsoluteSize.Y >= AbsoluteSize.Y then
                    self.Icon = "INFO"
                    self.Status = "Problem Detected"
                    break
                end
            end
        end
    end

    --Connect the events.
    self.Events[ScreenGui] = {}
    table.insert(self.Events[ScreenGui],ScreenGui.DescendantAdded:Connect(function(Ins)
        if not Ins:IsA("GuiObject") then return end
        table.insert(self.Events[ScreenGui],Ins:GetPropertyChangedSignal("AbsoluteSize"):Connect(CheckScreenGui))
        CheckScreenGui()
    end))
    CheckScreenGui()
end



return ScreenCoversTest