-- Module functions

function InterfaceModule.UpdateElectrons(balance)
	-- Change the text, that's really all there is to this
	local balance = balance or 0
	Interface.OpenMeta.Electrons.Text = FormatThousands(balance)
	--Interface.OpenMeta.Electrons.Text = ConvertToShortNum(balance)
end

function InterfaceModule.ToggleWindow(state)
	if ((not debounce) and (state ~= InterfaceModule.Open)) then
		debounce = true
		
		-- Tween the interface in or out
		Interface.MainMeta:TweenPosition(UDim2.new(0.5, 0, (state and 0.5) or 1.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1)
		wait(1.1)
		
		-- Change the variables
		InterfaceModule.Open = state
		debounce = false
	end
end

function InterfaceModule.ToggleSpawnWindow(state)
	if ((not spawndebounce)) then
		spawndebounce = true
		
		-- Tween the interface in or out
		Interface.SpawnMeta:TweenPosition(UDim2.new(0.5, 0, (state and 0.5) or 1.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quart, 1)
		wait(1.1)
		
		spawndebounce = false
	end
end

function InterfaceModule.ChangePage(page)
	if (Options:FindFirstChild(page)) then
		if ((not InterfaceModule.Changing) and (InterfaceModule.Page ~= page)) then
			InterfaceModule.Changing = true
			
			-- Set the UIPageLayout current page to the corresponding page for the button
			local index = Options:FindFirstChild(page)
			
			local previousButton = Options:FindFirstChild(InterfaceModule.Page)
			local newButton = Options:FindFirstChild(page)
	
			-- Change the colour for the previous button
			previousButton.Font = Enum.Font.Gotham
			previousButton.TextColor3 = Color3.fromRGB(227, 227, 227)
	
			-- Change the colour for the current button
			newButton.Font = Enum.Font.GothamBlack
			newButton.TextColor3 = Color3.new(1, 1, 1)
	
			-- Change the page
			Interface.MainMeta.Content.Content.UIPageLayout:JumpToIndex(index.LayoutOrder)
			
			-- Wait until the animation is finished
			wait(Interface.MainMeta.Content.Content.UIPageLayout.TweenTime + 0.1)
			
			-- Update the page variables
			InterfaceModule.Page = page
			InterfaceModule.Changing = false
		end
	end
end
