-- padding between each entry

local ENTRY_MARGIN = 1

local explorerPanel = script.Parent
local Input = game:GetService("UserInputService")
local HoldingCtrl = false
local HoldingShift = false

local addObject
local removeObject
local gameChildren = {}

table.insert(gameChildren, game:GetService("Workspace"))
table.insert(gameChildren, game:GetService("Players"))
table.insert(gameChildren, game:GetService("Lighting"))
table.insert(gameChildren, game:GetService("ReplicatedFirst"))
table.insert(gameChildren, game:GetService("ReplicatedStorage"))


pcall(function()
	table.insert(gameChildren, game:GetService("CoreGui"))
end)

table.insert(gameChildren, game:GetService("StarterGui"))
table.insert(gameChildren, game:GetService("StarterPack"))
table.insert(gameChildren, game:GetService("StarterPlayer"))
table.insert(gameChildren, game:GetService("SoundService"))
table.insert(gameChildren, game:GetService("Chat"))
table.insert(gameChildren, game:GetService("LocalizationService"))
table.insert(gameChildren, game:GetService("TestService"))

local childrenGame = {}

childrenGame[game:GetService("Workspace")] = true
childrenGame[game:GetService("Players")] = true
childrenGame[game:GetService("Lighting")] = true
childrenGame[game:GetService("ReplicatedFirst")] = true
childrenGame[game:GetService("ReplicatedStorage")] = true

pcall(function()
	childrenGame[game:GetService("CoreGui")] = true
end)

childrenGame[game:GetService("StarterGui")] = true
childrenGame[game:GetService("StarterPack")] = true
childrenGame[game:GetService("StarterPlayer")] = true
childrenGame[game:GetService("SoundService")] = true
childrenGame[game:GetService("Chat")] = true
childrenGame[game:GetService("LocalizationService")] = true
childrenGame[game:GetService("TestService")] = true

local MuteHiddenItems = true

local DexOutput = Instance_new("Folder")
DexOutput.Name = "Output"
local DexOutputMain = Instance_new("ScreenGui", DexOutput)
DexOutputMain.Name = "Dex Output"

local HiddenEntries = Instance_new("Folder")
local HiddenGame = Instance_new("Folder")
HiddenEntries.Name = "HiddenEntriesParent"
local HiddenEntriesMain = Instance_new("TextButton", HiddenEntries)
Instance_new("Folder", HiddenEntriesMain)

local function NameHiddenEntries()
	if MuteHiddenItems then
		HiddenEntriesMain.Name = "Expand to view (" .. (#game:children() - #gameChildren) .. ") hidden items"
	else
		HiddenEntriesMain.Name = "Collapse to hide (" .. (#game:children() - #gameChildren) .. ") more items"
	end
end

NameHiddenEntries()

local function print(...)
	local Obj = Instance_new("Dialog")
	Obj.Parent = DexOutputMain
	Obj.Name = ""
	for i,v in pairs(table.pack(...)) do
		Obj.Name = Obj.Name .. tostring(v) .. " "
	end
end

explorerPanel:WaitForChild("GetPrint").OnInvoke = function()
	return print
end
