local Background
function F4Menu_OpenTextBox(text1, text2, cmd, t)
	if IsValid(Background) then Background:Close() end
	Background = vgui.Create("DFrame")
	Background:SetTitle("")
	Background:SetDraggable(false)
	Background:ShowCloseButton(false)
	Background:SetSize(ScrW(), ScrH())
	Background:SetPos(0, 0)
	Background:MakePopup()
	Background:ParentToHUD()
	Background.Paint = function()
	end
	Background.Think = function()
		if t == 1 then
			if (!IsValid(F4Menu) or !F4Menu:IsVisible()) then
				Background:Close()
			end
		elseif t == 2 then
			if !IsValid(F2_KeysMenu) then
				Background:Close()
			end
		end
	end
	local FrameWindow = vgui.Create("DFrame", Background)
	FrameWindow:SetSize(500, 150)
	FrameWindow:Center()
	FrameWindow:SetTitle("")
	FrameWindow:ShowCloseButton(false)
	FrameWindow.Init = function(self)
		self.StartTime = SysTime()
	end
	FrameWindow.Paint = function(self, w, h)
		Derma_DrawBackgroundBlur(self, self.StartTime)
		draw.RoundedBox(0, 0, 0, w, h, F4Menu_Reskin.Colors[1])
		draw.RoundedBox(0, 1, 1, w - 2, h - 2, F4Menu_Reskin.Colors[2])
		draw.RoundedBox(0, 0, 0, w, 50, F4Menu_Reskin.Colors[14])
		draw.SimpleText(text1, "F4Menu_BoxTitleFont", 20, 15, color_white)
		draw.SimpleText(text2, "F4Menu_BoxFont", w / 2, 62, Color(167, 167, 167, 255), TEXT_ALIGN_CENTER)
		surface.SetDrawColor(F4Menu_Reskin.Colors[16])
		surface.DrawLine(1, 1, w - 2, 1)
		surface.DrawLine(1, 1, 1, 49)
		surface.DrawLine(w - 2, 1, w - 2, 49)
	end
	local Close = vgui.Create("DButton", FrameWindow)
	Close:SetSize(50, 20)
	Close:SetPos(FrameWindow:GetWide() - 60, 0)
	Close:SetText("X")
	Close:SetFont("F4Menu_CloseFont")
	Close:SetTextColor(color_white)
	Close.Paint = function(self, w, h)
		local kcol
		if self:IsHovered() then
			kcol = Color(255, 150, 150, 255)
		else
			kcol = Color(175, 100, 100)
		end
		draw.RoundedBoxEx(0, 0, 0, w, h, Color(255, 150, 150, 255), false, false, true, true)
		draw.RoundedBoxEx(0, 1, 0, w - 2, h - 1, kcol, false, false, true, true)
	end
	Close.DoClick = function()
		Background:Close()
	end
	local Text = vgui.Create("DTextEntry", FrameWindow)
	Text:SetText("")
	Text:SetPos(FrameWindow:GetWide() / 2 - 100, FrameWindow:GetTall() - 60)
	Text:SetSize(200, 20	)
	Text.Paint = function(self, w, h)
		draw.RoundedBox(0, 0, 0, w, h, Color(230,230,230))
		draw.RoundedBox(0, 1, 1, w-2, h-2, Color(255,255,255))
		self:DrawTextEntryText(Color(30, 30, 30), Color(149, 240, 193), Color(0, 0, 0))
	end
	local AcceptButton = vgui.Create("DButton", FrameWindow)
	AcceptButton:SetSize(90, 20)
	AcceptButton:SetPos(FrameWindow:GetWide() / 2 - 45, FrameWindow:GetTall() - 34)
	AcceptButton:SetText("Akzeptieren")
	AcceptButton:SetFont("F4Menu_CloseFont")
	AcceptButton:SetTextColor(Color(255,255,255))
	AcceptButton.Paint = function(self, w, h)
		local col
		if self:IsHovered() then
			col = F4Menu_Reskin.Colors[5]
		else
			col = Color(36, 165, 221)
		end
		draw.RoundedBox(0, 0, 0, w, h, Color(16, 96, 130))
		draw.RoundedBox(0, 1, 1, w - 2, h - 2, col)
	end
	AcceptButton.DoClick = function()
		local amt = Text:GetValue()
		if amt then
			local str = "/"..cmd.." "..amt
			RunConsoleCommand("say", str)
		end
		Background:Close()
	end
end

function F4Menu_OpenPlayerBox(text1, text2, cmd, t)
	if IsValid(Background) then Background:Close() end
	Background = vgui.Create("DFrame")
	Background:SetTitle("")
	Background:SetDraggable(false)
	Background:ShowCloseButton(false)
	Background:SetSize(ScrW(), ScrH())
	Background:SetPos(0, 0)
	Background:MakePopup()
	Background:ParentToHUD()
	Background.Paint = function()
	end
	Background.Think = function()
		if t == 1 then
			if (!IsValid(F4Menu) or !F4Menu:IsVisible()) then
				Background:Close()
			end
		elseif t == 2 then
			if !IsValid(F2_KeysMenu) then
				Background:Close()
			end
		end
	end
	local FrameWindow = vgui.Create("DFrame", Background)
	FrameWindow:SetSize(500, 150)
	FrameWindow:Center()
	FrameWindow:SetTitle("")
	FrameWindow:ShowCloseButton(false)
	FrameWindow.Init = function(self)
		self.StartTime = SysTime()
	end
	FrameWindow.Paint = function(self, w, h)
		Derma_DrawBackgroundBlur(self, self.StartTime)
		draw.RoundedBox(0, 0, 0, w, h, F4Menu_Reskin.Colors[1])
		draw.RoundedBox(0, 1, 1, w - 2, h - 2, F4Menu_Reskin.Colors[2])
		draw.RoundedBox(0, 0, 0, w, 50, F4Menu_Reskin.Colors[14])
		draw.SimpleText(text1, "F4Menu_BoxTitleFont", 20, 15, color_white)
		draw.SimpleText(text2, "F4Menu_BoxFont", w / 2, 62, Color(167, 167, 167, 255), TEXT_ALIGN_CENTER)
		surface.SetDrawColor(F4Menu_Reskin.Colors[16])
		surface.DrawLine(1, 1, w - 2, 1)
		surface.DrawLine(1, 1, 1, 49)
		surface.DrawLine(w - 2, 1, w - 2, 49)
	end
	local Close = vgui.Create("DButton", FrameWindow)
	Close:SetSize(50, 20)
	Close:SetPos(FrameWindow:GetWide() - 60, 0)
	Close:SetText("X")
	Close:SetFont("F4Menu_CloseFont")
	Close:SetTextColor(color_white)
	Close.Paint = function(self, w, h)
		local kcol
		if self:IsHovered() then
			kcol = Color(255, 150, 150, 255)
		else
			kcol = Color(175, 100, 100)
		end
		draw.RoundedBoxEx(0, 0, 0, w, h, Color(255, 150, 150, 255), false, false, true, true)
		draw.RoundedBoxEx(0, 1, 0, w - 2, h - 1, kcol, false, false, true, true)
	end
	Close.DoClick = function()
		Background:Close()
	end
	local SelectPlayers = vgui.Create("DComboBox", FrameWindow)
	SelectPlayers:SetPos(FrameWindow:GetWide() / 2 - 100, 85)
	SelectPlayers:SetSize(200, 20)
	local players = player.GetAll()
	table.sort(players, function(a, b) return a:Name() < b:Name() end)
	for _,v in ipairs(players) do
		SelectPlayers:AddChoice(v:Name(), v:UserID())
	end
	local AcceptButton = vgui.Create("DButton", FrameWindow)
	AcceptButton:SetSize(90, 20)
	AcceptButton:SetPos(FrameWindow:GetWide() / 2 - 45, FrameWindow:GetTall() - 34)
	AcceptButton:SetText("Akzeptieren")
	AcceptButton:SetFont("F4Menu_CloseFont")
	AcceptButton:SetTextColor(Color(255,255,255))
	AcceptButton.Paint = function(self, w, h)
		local col
		if self:IsHovered() then
			col = F4Menu_Reskin.Colors[5]
		else
			col = Color(36, 165, 221)
		end
		draw.RoundedBox(0, 0, 0, w, h, Color(16, 96, 130))
		draw.RoundedBox(0, 1, 1, w - 2, h - 2, col)
	end
	AcceptButton.DoClick = function()
		local _, id = SelectPlayers:GetSelected()
		if id then
			local str = "/"..cmd.." "..id
			RunConsoleCommand("say", str)
		end
		Background:Close()
	end
end

function F4Menu_OpenPlayerReasonBox(text1, text2, text3, cmd, t)
	if IsValid(Background) then Background:Close() end
	Background = vgui.Create("DFrame")
	Background:SetTitle("")
	Background:SetDraggable(false)
	Background:ShowCloseButton(false)
	Background:SetSize(ScrW(), ScrH())
	Background:SetPos(0, 0)
	Background:MakePopup()
	Background:ParentToHUD()
	Background.Paint = function()
	end
	Background.Think = function()
		if t == 1 then
			if (!IsValid(F4Menu) or !F4Menu:IsVisible()) then
				Background:Close()
			end
		elseif t == 2 then
			if !IsValid(F2_KeysMenu) then
				Background:Close()
			end
		end
	end
	local FrameWindow = vgui.Create("DFrame", Background)
	FrameWindow:SetSize(500, 218)
	FrameWindow:Center()
	FrameWindow:SetTitle("")
	FrameWindow:ShowCloseButton(false)
	FrameWindow.Init = function(self)
		self.StartTime = SysTime()
	end
	FrameWindow.Paint = function(self, w, h)
		Derma_DrawBackgroundBlur(self, self.StartTime)
		draw.RoundedBox(0, 0, 0, w, h, F4Menu_Reskin.Colors[1])
		draw.RoundedBox(0, 1, 1, w - 2, h - 2, F4Menu_Reskin.Colors[2])
		draw.RoundedBox(0, 0, 0, w, 50, F4Menu_Reskin.Colors[14])
		draw.SimpleText(text1, "F4Menu_BoxTitleFont", 20, 15, color_white)
		draw.SimpleText(text2, "F4Menu_BoxFont", w / 2, 60, Color(167, 167, 167, 255), TEXT_ALIGN_CENTER)
		draw.SimpleText(text3, "F4Menu_BoxFont", w / 2, 120, Color(167, 167, 167, 255), TEXT_ALIGN_CENTER)
		surface.SetDrawColor(F4Menu_Reskin.Colors[16])
		surface.DrawLine(1, 1, w - 2, 1)
		surface.DrawLine(1, 1, 1, 49)
		surface.DrawLine(w - 2, 1, w - 2, 49)
	end
	local Close = vgui.Create("DButton", FrameWindow)
	Close:SetSize(50, 20)
	Close:SetPos(FrameWindow:GetWide() - 60, 0)
	Close:SetText("X")
	Close:SetFont("F4Menu_CloseFont")
	Close:SetTextColor(color_white)
	Close.Paint = function(self, w, h)
		local kcol
		if self:IsHovered() then
			kcol = Color(255, 150, 150, 255)
		else
			kcol = Color(175, 100, 100)
		end
		draw.RoundedBoxEx(0, 0, 0, w, h, Color(255, 150, 150, 255), false, false, true, true)
		draw.RoundedBoxEx(0, 1, 0, w - 2, h - 1, kcol, false, false, true, true)
	end
	Close.DoClick = function()
		Background:Close()
	end
	local target
	local SelectPlayers = vgui.Create("DComboBox", FrameWindow)
	SelectPlayers:SetPos(FrameWindow:GetWide() / 2 - 100, 85)
	SelectPlayers:SetSize(200, 20)
	local players = player.GetAll()
	table.sort(players, function(a, b) return a:Name() < b:Name() end)
	for _,v in ipairs(players) do
		SelectPlayers:AddChoice(v:Name(), v:UserID())
	end
	local Text = vgui.Create("DTextEntry", FrameWindow)
	Text:SetText("")
	Text:SetPos(FrameWindow:GetWide() / 2 - 100, FrameWindow:GetTall() - 74)
	Text:SetSize(200, 20)
	Text.Paint = function(self, w, h)
		draw.RoundedBox(0, 0, 0, w, h, Color(230,230,230))
		draw.RoundedBox(0, 1, 1, w-2, h-2, Color(255,255,255))
		self:DrawTextEntryText(Color(30, 30, 30), Color(149, 240, 193), Color(0, 0, 0))
	end
	local AcceptButton = vgui.Create("DButton", FrameWindow)
	AcceptButton:SetSize(100, 20)
	AcceptButton:SetPos(FrameWindow:GetWide() / 2 - 50, FrameWindow:GetTall() - 34)
	AcceptButton:SetText("Akzeptieren")
	AcceptButton:SetFont("F4Menu_CloseFont")
	AcceptButton:SetTextColor(Color(255,255,255))
	AcceptButton.Paint = function(self, w, h)
		local col
		if self:IsHovered() then
			col = F4Menu_Reskin.Colors[5]
		else
			col = Color(36, 165, 221)
		end
		draw.RoundedBox(0, 0, 0, w, h, Color(16, 96, 130))
		draw.RoundedBox(0, 1, 1, w - 2, h - 2, col)
	end
	AcceptButton.DoClick = function()
		local _, id = SelectPlayers:GetSelected()
		if id then
			local amt = Text:GetValue()
			if amt then
				local str = "/"..cmd.." "..id.." "..amt
				RunConsoleCommand("say", str)
			end
		end
		Background:Close()
	end
end