local I=require(((game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\080\114\111\106\101\099\116")):WaitForChild("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101"))local x=I:GetResource("\069\120\116\101\114\110\097\108\085\116\105\108\046\078\101\120\117\115\073\110\115\116\097\110\099\101\046\078\101\120\117\115\079\098\106\101\099\116")local u=x:Extend()u:SetClassName("\065\115\112\101\099\116\082\097\116\105\111\083\119\105\116\099\104\101\114")function u.__new(k,I,x,u,U)k:InitializeSuper()k.CurrentState="\085\110\105\116\105\097\108\105\122\101\100"k.Frame=I k.MinimumAspectRatioForLandscape=x k.SwitchCallbacks={Landscape=u,Portrait=U};(I:GetPropertyChangedSignal("\065\098\115\111\108\117\116\101\083\105\122\101")):Connect(function()k:UpdateState()end)k:UpdateState()end function u.UpdateState(I)local x=I.Frame.AbsoluteSize.X/I.Frame.AbsoluteSize.Y local u=x>I.MinimumAspectRatioForLandscape and"\076\097\110\100\115\099\097\112\101"or"\080\111\114\116\114\097\105\116"if u~=I.CurrentState then I.CurrentState=u I.SwitchCallbacks[u]()end end return u
--[[
TheNexusAvenger

Runs callbacks when the aspect ratio of a GUI
requires switching for portrait and landscape.
--]]

local ReplicatedStorageProject = require(game:GetService("ReplicatedStorage"):WaitForChild("Project"):WaitForChild("ReplicatedStorage"))

local NexusObject = ReplicatedStorageProject:GetResource("ExternalUtil.NexusInstance.NexusObject")

local AspectRatioSwitcher = NexusObject:Extend()
AspectRatioSwitcher:SetClassName("AspectRatioSwitcher")



--[[
Creates an aspect ratio swticher.
--]]
function AspectRatioSwitcher:__new(Frame,MinimumAspectRatioForLandscape,SwitchToLandscapeCallback,SwitchToPortraitCallback)
    self:InitializeSuper()

    --Store the state.
    self.CurrentState = "Unitialized"
    self.Frame = Frame
    self.MinimumAspectRatioForLandscape = MinimumAspectRatioForLandscape
    self.SwitchCallbacks = {
        Landscape = SwitchToLandscapeCallback,
        Portrait = SwitchToPortraitCallback,
    }

    --Create the changed size event.
    Frame:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
        self:UpdateState()
    end)
    self:UpdateState()
end

--[[
Updates the state.
--]]
function AspectRatioSwitcher:UpdateState()
    --Determine the new state.
    local AspectRatio = self.Frame.AbsoluteSize.X/self.Frame.AbsoluteSize.Y
    local NewState = (AspectRatio > self.MinimumAspectRatioForLandscape and "Landscape" or "Portrait")

    --Call the callback if the state changed.
    if NewState ~= self.CurrentState then
        self.CurrentState = NewState
        self.SwitchCallbacks[NewState]()
    end
end



return AspectRatioSwitcher