--[[
	menu_plugins/OubHack/oubhack_derma.lua
	Oubliette | (STEAM_0:1:34029133)
	===DStream===
]]

/******************************************************************************
 .d88888b.  888     888 888888b.   888    888        d8888  .d8888b.  888    d8P  
d88P" "Y88b 888     888 888  "88b  888    888       d88888 d88P  Y88b 888   d8P   
888     888 888     888 888  .88P  888    888      d88P888 888    888 888  d8P    
888     888 888     888 8888888K.  8888888888     d88P 888 888        888d88K     
888     888 888     888 888  "Y88b 888    888    d88P  888 888        8888888b    
888     888 888     888 888    888 888    888   d88P   888 888    888 888  Y88b   
Y88b. .d88P Y88b. .d88P 888   d88P 888    888  d8888888888 Y88b  d88P 888   Y88b  
 "Y88888P"   "Y88888P"  8888888P"  888    888 d88P     888  "Y8888P"  888    Y88b 
 By Oubliete and UnknownAlias
*******************************************************************************/

if !ConVarExists("aimbot_speed") then CreateClientConVar("aimbot_speed",360,true,false) end -- #4 arg, yeeaah like I'm that stupid.
if !ConVarExists("oh_aimbot_enabled") then CreateClientConVar("oh_aimbot_enabled","false",true,false) end

oubhack.cp_offset = 0;

-------------------------------------------------------------------------------------------------|


-------------------------------------------------------------------------------------------------|


-------------------------------------------------------------------------------------------------|


-------------------------------------------------------------------------------------------------|

function oubhack:GetESPPanel(w,h)
	if self.ESPPanel then self.ESPPanel:Remove() self.ESPPanel = nil end
	self.ESPPanel = self:CreateVgui("DFrame")
		self.ESPPanel:SetSize(w,h)
		self.ESPPanel:SetSkin("oubhack")
		--self.ESPPanel:MakePopup()
		self.ESPPanel:SetVisible(false)
		self.ESPPanel:SetTitle("OubHack ESP configuration menu")
		self.ESPPanel:ShowCloseButton(false)
		self.ESPPanel:SetSizable(true)
		function self.ESPPanel:update()
			self:Clear(true)
						self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
				end
				
		end
		
	self.ESPPanel:update();
	return self.ESPPanel; 
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetXRayPanel(w,h)
	if self.XRayPanel then self.XRayPanel:Remove() self.XRayPanel = nil end
	self.XRayPanel = self:CreateVgui("DFrame")
		self.XRayPanel:SetSize(w,h)
		self.XRayPanel:SetSkin("oubhack")
	--	self.XRayPanel:MakePopup()
		self.XRayPanel:SetVisible(false)
		self.XRayPanel:SetTitle("OubHack X-Ray configuration menu")
		self.XRayPanel:ShowCloseButton(false)
		self.XRayPanel:SetSizable(true)
		function self.XRayPanel:update()
			self:Clear(true)
						self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
		end
		
	self.XRayPanel:update();
	return self.XRayPanel;
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetFriendsPanel(w,h)
	if self.FriendsPanel then self.FriendsPanel:Remove() self.FriendsPanel = nil end
	self.FriendsPanel = self:CreateVgui("DFrame")
		self.FriendsPanel:SetSize(w,h)
		self.FriendsPanel:SetSkin("oubhack")
	--	self.FriendsPanel:MakePopup()
		self.FriendsPanel:SetVisible(false)
		self.FriendsPanel:SetTitle("OubHack friends manager")
		self.FriendsPanel:ShowCloseButton(false)
		self.FriendsPanel:SetSizable(true)
		function self.FriendsPanel:update()
			self:Clear(true)
						self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(22,22)
				self.Minimize:SetPos(self:GetWide()-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					if not oubhack.Frame then return false end -- Already closed
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
				self.Minimize.Think = function()
					self.Minimize:SetPos(self:GetWide()-self.Minimize:GetWide(),0)
				end
			
			-------------------------------------------------------------------------------------------------------------------------------------------|
			----------------------------------------------------------------- Targets -----------------------------------------------------------------|
			-------------------------------------------------------------------------------------------------------------------------------------------|
			
			self.TargetList = oubhack:CreateVgui("DListView",self)
				self.TargetList:SetPos(20,22)
				self.TargetList:SetSize(300,275)
				self.TargetList:SetMultiSelect(false)
				self.TargetList:AddColumn("Name")
				self.TargetList:AddColumn("Is Steam Friend")
				self.TargetList:AddColumn("User Group")
				self.TargetList.OnRowSelected = function(panel,line)
					if !panel or !line then return false end;
					self.Selected = panel:GetLine(line):GetValue(1);
					self.SelectedLine = line;
				end
				for k,v in pairs(oubhack:GetTargets()) do
					self.TargetList:AddLine(v:Nick(),string.BoolToYN(oubhack:IsSteamFriend(v)),oubhack:GetUserGroup(v))
				end
				
			self.AddFriend = oubhack:CreateVgui("DButton",self)
				self.AddFriend:SetPos(20,self.TargetList:GetTall()+22)
				self.AddFriend:SetSize(self.TargetList:GetWide(),50)
				self.AddFriend:SetText("Add Friend")
				self.AddFriend.DoClick = function()
					if !self.Selected or !self.SelectedLine then return false end;
					oubhack:AddFriend(player.FindByName(self.Selected))
					self.TargetList:RemoveLine(self.SelectedLine)
					self.FriendsList:AddLine(self.Selected,string.BoolToYN(oubhack:IsSteamFriend(player.FindByName(self.Selected))),oubhack:GetUserGroup(player.FindByName(self.Selected)))
					self.Selected = nil;
					self.SelectedLine = nil;
				end
				self.TargetList.DoDoubleClick = self.AddFriend.DoClick
			-------------------------------------------------------------------------------------------------------------------------------------------|
			----------------------------------------------------------------- Friends -----------------------------------------------------------------|
			-------------------------------------------------------------------------------------------------------------------------------------------|
			
			self.FriendsList = oubhack:CreateVgui("DListView",self)
				self.FriendsList:SetPos(80+self.TargetList:GetWide(),22)
				self.FriendsList:SetSize(300,275)
				self.FriendsList:SetMultiSelect(false)
				self.FriendsList:AddColumn("Name")
				self.FriendsList:AddColumn("Is Steam Friend")
				self.FriendsList:AddColumn("User group")
				self.FriendsList.OnRowSelected = function(panel,line)
					self.RSelected = panel:GetLine(line):GetValue(1);
					self.RSelectedLine = line;
				end
				for k,v in pairs(oubhack.friends) do
					self.FriendsList:AddLine(v:Nick(),string.BoolToYN(oubhack:IsSteamFriend(v)),oubhack:GetUserGroup(v))
				end
			self.RemoveFriend = oubhack:CreateVgui("DButton",self)
				self.RemoveFriend:SetPos(80+self.FriendsList:GetWide(),self.TargetList:GetTall()+22)
				self.RemoveFriend:SetSize(self.TargetList:GetWide(),50)
				self.RemoveFriend:SetText("Remove Friend")
				self.RemoveFriend.DoClick = function()
					if !self.RSelected or !self.RSelectedLine then return false end;
					oubhack:RemoveFriend(player.FindByName(self.RSelected))
					self.FriendsList:RemoveLine(self.RSelectedLine)
					self.TargetList:AddLine(self.RSelected,string.BoolToYN(oubhack:IsSteamFriend(player.FindByName(self.RSelected))),oubhack:GetUserGroup(player.FindByName(self.RSelected)))
					self.RSelected = nil;
					self.RSelectedLine = nil;
				end
				self.FriendsList.DoDoubleClick = self.RemoveFriend.DoClick
		end
		
	self.FriendsPanel:update();
	return self.FriendsPanel;
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetHUDPanel(w,h)
	if self.HUDPanel then self.HUDPanel:Remove() self.HUDPanel = nil end
	self.HUDPanel = self:CreateVgui("DFrame")
		self.HUDPanel:SetSize(w,h)
		self.HUDPanel:SetSkin("oubhack")
	--	self.HUDPanel:MakePopup()
		self.HUDPanel:SetVisible(false)
		self.HUDPanel:SetTitle("OubHack HUD configuration menu")
		self.HUDPanel:ShowCloseButton(false)
		self.HUDPanel:SetSizable(true)
		function self.HUDPanel:update()
			self:Clear(true)
					self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
		end
		
	self.HUDPanel:update();
	return self.HUDPanel;
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetGroupsPanel(w,h)
	if self.GroupsPanel then self.GroupsPanel:Remove() self.GroupsPanel = nil; end
	self.GroupsPanel = self:CreateVgui("DFrame")
		self.GroupsPanel:SetSize(w,h)
		self.GroupsPanel:SetSkin("oubhack")
		self.GroupsPanel:MakePopup()
		self.GroupsPanel:SetTitle("OubHack grouping menu")
		self.GroupsPanel:SetVisible(false)
		self.GroupsPanel:ShowCloseButton(false)
		self.GroupsPanel:SetSizable(true)
		self:CheckGroups() -- It won't actaully check if there's no players on the map. this is a easy way around that.
		function self.GroupsPanel:update()
			self:Clear(true)
			self.Selected = {};
			self.Selected.Name = "None";
			self.Selected.Index = 1;
			
			self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
				
			self.TargList = oubhack:CreateVgui("DListView",self)
				self.TargList:SetSize(((ScrW()/2)),(ScrH()/2)-100)
				self.TargList:SetPos(ScrW()/2-self.TargList:GetWide(),20)
				self.TargList:SetMultiSelect(false)
				self.TargList:AddColumn("Name")
				self.TargList:AddColumn("OubHack freind")
				self.TargList:AddColumn("Steam freind")
				self.TargList:AddColumn("Team")
				for k,v in pairs(oubhack:GetPossibleTargets()) do
					if v:IsValid() then
						self.TargList:AddLine(v:Nick(),string.BoolToYN(oubhack:IsFriend(v)),string.BoolToYN(oubhack:IsSteamFriend(v)),oubhack:GetGroup(v).Name)
					end
				end
				self.TargList.OnRowSelected = function(panel,line)
					local name = panel:GetLine(line):GetValue(1)
					local ply = player.FindByName(name)
					panel:GetLine(line):SetValue(4,self.Selected.Name)
					oubhack:GroupPlayer(ply,self.Selected.Name)
					self.GroupList:GetLine(self.Selected.Index):SetValue(2,#oubhack.groups[self.Selected.Index].Mbrs)
				end
			
			self.CreateGroupName = oubhack:CreateVgui("DTextEntry",self)
				self.CreateGroupName:SetPos(0,20+self.TargList:GetTall())
				self.CreateGroupName:SetSize(175,20)
				self.CreateGroupName:SetEnterAllowed(true)
				self.CreateGroupName.OnEnter = function()
					if self.CreateGroupName:GetValue() == "" then return false end
					local result = oubhack:CreateGroup(self.CreateGroupName:GetValue())
					if result then self.GroupList:AddLine(self.CreateGroupName:GetValue(),0) end
					self.CreateGroupName:SetValue("")
				end
				
			self.AddGroupButton = oubhack:CreateVgui("DButton",self)
				self.AddGroupButton:SetPos(0,20+self.TargList:GetTall()+self.CreateGroupName:GetTall())
				self.AddGroupButton:SetSize(175,60)
				self.AddGroupButton:SetText("Add Group")
				self.AddGroupButton.DoClick = self.CreateGroupName.OnEnter
				
			self.GroupList = oubhack:CreateVgui("DListView",self)
				self.GroupList:SetSize((ScrW()/2)-self.AddGroupButton:GetWide()-150,self.AddGroupButton:GetTall()+self.CreateGroupName:GetTall())
				self.GroupList:SetPos(self.AddGroupButton:GetWide(),20+self.TargList:GetTall())
				self.GroupList:SetMultiSelect(false)
				self.GroupList:AddColumn("Name")
				self.GroupList:AddColumn("Members")
				self.GroupList.OnRowSelected = function(panel,line)
					self.Selected = {Index=line,Name=panel:GetLine(line):GetValue(1)}
				end
				self.GroupList.DoDoubleClick = function(panel,line)
					oubhack:RemoveGroup(panel:GetLine(line):GetValue(1))
					self.GroupList:RemoveLine(line)
				end
				for k,v in pairs(oubhack.groups) do
					if v.Name != "None" then
						self.GroupList:AddLine(v.Name,#v.Mbrs)
					end
				end

		end
		
	self.GroupsPanel:update();
	return self.GroupsPanel;
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetMovementPanel(w,h)
	if self.MovementPanel then self.MovementPanel:Remove() self.MovementPanel = nil end
	self.MovementPanel = self:CreateVgui("DFrame")
		self.MovementPanel:SetSize(w,h)
		self.MovementPanel:SetSkin("oubhack")
		--self.MovementPanel:MakePopup()
		self.MovementPanel:SetVisible(false)
		self.MovementPanel:SetTitle("OubHack Movement configuration menu")
		self.MovementPanel:ShowCloseButton(false)
		self.MovementPanel:SetSizable(true)
		function self.MovementPanel:update()
			self:Clear(true)
						self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
		end
		
	self.MovementPanel:update();
	return self.MovementPanel;
end

-------------------------------------------------------------------------------------------------|


function oubhack:GetSetupPanel(w,h)
	if self.SetupPanel then self.SetupPanel:Remove() end
	self.SetupPanel = self:CreateVgui("DFrame")
		self.SetupPanel:SetSize(w,h)
		self.SetupPanel:SetSkin("oubhack")
	--	self.SetupPanel:MakePopup()
		self.SetupPanel:SetVisible(false)
		self.SetupPanel:SetTitle("OubHack Save/load setups and configurations")
		self.SetupPanel:ShowCloseButton(false)
		self.SetupPanel:SetSizable(true)
		function self.SetupPanel:update()
			self:Clear(true)
					self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
		end
		
	self.SetupPanel:update();
	return self.SetupPanel;
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetMiscPanel(w,h)
	if self.MiscPanel then self.MiscPanel:Remove() self.MiscPanel = nil; end
	self.MiscPanel = self:CreateVgui("DFrame")
		self.MiscPanel:SetSize(w,h)
		self.MiscPanel:SetSkin("oubhack")
	--	self.MiscPanel:MakePopup()
		self.MiscPanel:SetVisible(false)
		self.MiscPanel:SetTitle("OubHack misc settings")
		self.MiscPanel:ShowCloseButton(false)
		self.MiscPanel:SetSizable(true)
		function self.MiscPanel:update()
			self:Clear(true)
						self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
		end
		
	self.MiscPanel:update();
	return self.MiscPanel;
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetRadarPanel(w,h)
	if self.BindPanel then self.BindPanel:Remove() self.BindPanel = nil end
	self.BindPanel = self:CreateVgui("DFrame")
		self.BindPanel:SetSize(w,h)
		self.BindPanel:SetSkin("oubhack")
	--	self.BindPanel:MakePopup()
		self.BindPanel:SetVisible(false)
		self.BindPanel:SetTitle("OubHack binding manager")
		self.BindPanel:ShowCloseButton(false)
		self.BindPanel:SetSizable(true)
		function self.BindPanel:update()
			self:Clear(true)
						self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end

				self.Test = oubhack:CreateVgui("oh_DRadar",self)
					self.Test:SetSize(150,150)
					self.Test:SetPos(50,50)
		end
		
	self.BindPanel:update();
	return self.BindPanel;
end

-------------------------------------------------------------------------------------------------|

function oubhack:GetConsolePanel(w,h)
	if self.ConsolePanel then self.ConsolePanel:Remove() self.ConsolePanel = nil; end
	self.ConsolePanel = self:CreateVgui("DFrame")
		self.ConsolePanel:SetSize(w,h)
		self.ConsolePanel:SetSkin("oubhack")
		self.ConsolePanel:SetTitle("OubHack Console")
		self.ConsolePanel:MouseCapture()
		self.ConsolePanel:MakePopup()
		self.ConsolePanel:SetVisible(false)
		self.ConsolePanel:ShowCloseButton(false)
		self.ConsolePanel:SetSizable(true)
		
		function self.ConsolePanel:update()
			self:Clear(true)
			
					self.Minimize = oubhack:CreateVgui("DButton",self)
				self.Minimize:SetSize(20,20)
				self.Minimize:SetPos((ScrW()/2)-self.Minimize:GetWide(),0)
				self.Minimize:SetText("-")
				self.Minimize.DoClick = function()
					oubhack.Frame:ClosePanel(self)
					self.State = 0;
				end
				
					self.ConsoleScreen = oubhack:CreateVgui("RichText",self)
				self.ConsoleScreen:SetPos(20,20)
				self.ConsoleScreen:SetSize(ScrW()/2-42,ScrH()/2-60)
				self.ConsoleScreen:SetVerticalScrollbarEnabled(true)
				local oAT = self.ConsoleScreen.AppendText
				function self.ConsoleScreen:AppendText(text,color)
					if not self.ConsoleItems then self.ConsoleItems = {} end
					color = color or Color(255,255,255,255)
					self.ConsoleItems[#self.ConsoleItems+1] = {Text=text,Color=color};
					self:InsertColorChange(color.r,color.g,color.b,color.a)
					oAT(self,text)
				end
				function self.ConsoleScreen:SaveText()
					oubhack.ConsoleScreenItems = self.ConsoleItems or {};
				end
				
				if oubhack.ConsoleScreenItems then
					for k,v in pairs(oubhack.ConsoleScreenItems) do
						self.ConsoleScreen:AppendText(v.Text,v.Color)
					end
				end
				
					self.InputBox = oubhack:CreateVgui("DTextEntry",self)
				self.InputBox:SetPos(20,22+self.ConsoleScreen:GetTall())
				self.InputBox:SetSize(self.ConsoleScreen:GetWide()-40,20)
				self.InputBox:SetEditable(true)
				self.InputBox:SetEnterAllowed(true)
				self.InputBox.OnEnter = function()
					local str = self.InputBox:GetValue().. " " 
					local cmd = string.sub(str,1, string.find(str," ",1)-1 )
					local args = string.sub(str,string.len(cmd) + 2 ,string.len(str))
					if cmd == "" then self.ConsoleScreen:AppendText("]\n") return end
					if !table.HasValue( concommand.GetTable() /* replace this with a table of concommand names*/,cmd) then
						self.ConsoleScreen:AppendText("'"..cmd.."' is not a command.\n")
					else
						self.ConsoleScreen:AppendText("]"..cmd.."\n")
						RunConsoleCommand(cmd,args) -- Replace this with whatever you use to run it.
					end
					self.InputBox:SetValue("")
				end
				self.Submit = oubhack:CreateVgui("DButton",self)
					self.Submit:SetPos(22+self.InputBox:GetWide(),22+self.ConsoleScreen:GetTall())
					self.Submit:SetSize(self.ConsoleScreen:GetWide()-self.InputBox:GetWide()-2,self.InputBox:GetTall())
					self.Submit.DoClick = self.InputBox.OnEnter
					self.Submit:SetText("Submit")

		
		end
		
	self.ConsolePanel:update();
	return self.ConsolePanel;
end

function oubhack:OpenSettingsMenu(parent)
	if self.SetttingsMenuButton then 
		self.Frame = self:CreateVgui("oh_settings_tab",parent)
			self.Frame:SetPos(0,0)
			self.Frame:SetSize(ScrW()-100,100)
		self.Frame:AddSheet("Aimbot", self:GetAimbotPanel(w,h), "gui/silkicons/bomb", "Configure aimbot settings");
		self.Frame:AddSheet("ESP", self:GetESPPanel(w,h), "gui/silkicons/bomb", "Add and remove entities from\nthe ESP sensor");
		self.Frame:AddSheet("X-Ray", self:GetXRayPanel(w,h), "gui/silkicons/bomb", "Change what you can see\nthrough walls");
		self.Frame:AddSheet("HUD", self:GetHUDPanel(w,h), "gui/silkicons/bomb", "Change Heads Up Display\nsettings");
		self.Frame:AddSheet("Friends", self:GetFriendsPanel(w,h), "gui/silkicons/bomb", "Add and remove\nOubHack freinds");
		self.Frame:AddSheet("Groups", self:GetGroupsPanel(w,h), "gui/silkicons/bomb", "Set up player groups");
		self.Frame:AddSheet("Movement", self:GetMovementPanel(w,h), "gui/silkicons/bomb", "Change movement settings");
		self.Frame:AddSheet("Setups", self:GetSetupPanel(w,h), "gui/silkicons/bomb", "Load or Save OubHack\nconfigurations");
		self.Frame:AddSheet("Misc", self:GetMiscPanel(w,h), "gui/silkicons/bomb", "Miscellaneous settings");
		self.Frame:AddSheet("Radar", self:GetRadarPanel(w,h), "gui/silkicons/bomb", "Bind keys to\nOubHack actions");
		self.Frame:AddSheet("Console", self:GetConsolePanel(w,h), "gui/silkicons/bomb", "The oubhack console");
		self.Frame:Update()
	end
		
end

function oubhack:CloseSettingsMenu()
	if (self.Frame and self.Frame:IsVisible()) then
		if self.Frame.TPanel["Console"].ConsoleScreen then
			self.Frame.TPanel["Console"].ConsoleScreen:SaveText()
		end
		self.Frame:RemovePanels()
		self.Frame:Remove()
		self.Frame = nil
	end
end

function oubhack:Open()

	self.BasePanel = self:CreateVgui("DPanel")
		self.BasePanel:SetPos(0,2)
		self.BasePanel:SetSize(ScrW(),100)
		self.BasePanel.Paint = function() 
			
		end
		self.BasePanel.Remove = function()
			if self.PowerToggle then
				self.PowerToggle:Remove()
				self.PowerToggle = nil;
				self.SetttingsMenuButton:Remove()
				self.SetttingsMenuButton = nil;
			end
			if self.Frame then
				self.Frame:Remove()
				self.Frame = nil
			end
		end
		
	self.PowerToggle = self:CreateVgui("oh_DPowerToggle",self.BasePanel)
		self.PowerToggle:SetPos(ScrW()-100,0)
		self.PowerToggle:SetSize(100,100)
		self.PowerToggle:LogPos(ScrW(),0)
		self.PowerToggle:SetActive(!self.hidemode)
		self.PowerToggle.DoClick = function()
			if self.hidemode then
				self.hidemode = false;
				self.bg_main = Color(255,0,0,255)
			else
				self.bg_main = Color(255,0,0,255)
				self.hidemode = true;
			end
		end
	self.SetttingsMenuButton = self:CreateVgui("oh_DSettingsSwitch")
		self.SetttingsMenuButton:SetPos(0,0)
		self.SetttingsMenuButton:SetSize(50,100)
		self.SetttingsMenuButton.DoClick = function()
			if self.SetttingsMenuButton.Active then
				self.PowerToggle:Hide()
				oubhack:OpenSettingsMenu(self.SetttingsMenuButton)
			else
				self.PowerToggle:Show()
			end
		end
		self.SetttingsMenuButton.DoOpen = function()
			self.SetttingsMenuButton:SetDrawOnTop(true)
		end
		self.SetttingsMenuButton.DoClose = function()
			if oubhack.Frame then 
				oubhack:CloseSettingsMenu()
				
			end
		end	
end

function oubhack:Print(text,color)
	text = tostring(text) or "]\n"
	color = color or Color(255,255,255,255)
	if self.Frame and self.Frame.TPanel and self.Frame.TPanel["Console"] then
		self.Frame.TPanel["Console"].ConsoleScreen:AppendText( (text or "") .. "\n",color)
	else
		self.ConsoleScreenItems[#self.ConsoleScreenItems+1] = {Text=(text or "").."\n",Color=color}
	end
end

function oubhack:Log(text)
	file.Append("oubhack/logs.txt",text.."\n")
end


function oubhack:ToggleMenu()
	if self.BasePanel then
		self.BasePanel:Remove()
		self.BasePanel = nil
		gui.EnableScreenClicker(false)
	else
		self:Open()
		gui.EnableScreenClicker(true)
	end
end

concommand.Add("oh_toggle_menu",function() oubhack:ToggleMenu() end)

-------------------------------------------------------------------------------------------------|

local hfps = 0;
local lfps = 500;
local colour = Color(255,255,0,255)
local function FPS()
	local fps = (math.floor(1/FrameTime()))
	if tostring(fps) == "1.#INF" then return false end
	if fps > hfps then hfps = fps end
	if fps < lfps then lfps = fps end
	if fps < 10 then colour = Color(255,0,0,255) else colour = Color(255,255,0,255) end
	draw.DrawText("[ FPS: "..fps.."  -  Highest FPS : ".. hfps .. "   -  Lowest FPS: ".. lfps .. " ]", "ScoreboardText", ScrW()-325,5, colour,TEXT_ALIGN_LEFT);
end
hook.Add("HUDPaint","FPS",FPS)


