
//
// The server only runs this file so it can send it to the client
//

if ( SERVER ) then AddCSLuaFile( "options_menu.lua" ) return end

//
// This is designed so you can easily add to this list without editing this file
// Just make another autorun file that adds to this table
//
g_PlayerModels = g_PlayerModels or {}
	g_PlayerModels[ "none" ] 		= "vgui/player/kleiner"
	g_PlayerModels[ "mossman" ] 	= "vgui/player/mossman"
	g_PlayerModels[ "alyx" ] 		= "vgui/player/alyx"
	g_PlayerModels[ "barney" ] 		= "vgui/player/barney"
	g_PlayerModels[ "breen" ] 		= "vgui/player/breen"
	g_PlayerModels[ "monk" ] 		= "vgui/player/monk"
	g_PlayerModels[ "odessa" ] 		= "vgui/player/odessa"
	g_PlayerModels[ "zombie" ] 		= "vgui/player/zombie"
	g_PlayerModels[ "charple" ] 	= "vgui/player/charple"
	g_PlayerModels[ "combine" ] 	= "vgui/player/combine_soldier"
	g_PlayerModels[ "prison" ] 		= "vgui/player/combine_prison"
	g_PlayerModels[ "super" ] 		= "vgui/player/combine_super"
	g_PlayerModels[ "police" ] 		= "vgui/player/police"
	g_PlayerModels[ "gman" ] 		= "vgui/player/gman"


local function PlayerModel( CPanel )

	// Work it out so we have 2 per row
	local NumRows = Format( "%i", table.Count(g_PlayerModels) / 2 )
	
	local params = { Options = {}, Label = "#PlayerModel", Height = "128", Width = "128", Rows = NumRows }
	
	for k, v in pairs( g_PlayerModels ) do
		params.Options[ k ] = { Material = v, cl_playermodel = k }
	end
	
	CPanel:AddControl( "MaterialGallery", 	params )	

end


local function PlayerSettings( CPanel )

	CPanel:AddControl( "Header", { Text = "#Player Settings" }  )

	CPanel:AddControl( "TextBox", { Label = "#Name", 			Command = "name", 			WaitForEnter = "1" }  )
	CPanel:AddControl( "TextBox", { Label = "#Location", 		Command = "cl_location", 	WaitForEnter = "1" }  )
	CPanel:AddControl( "TextBox", { Label = "#Website", 		Command = "cl_website",		WaitForEnter = "1" }  )
	CPanel:AddControl( "TextBox", { Label = "#EmailAddress", 	Command = "cl_email", 		WaitForEnter = "1" }  )
	CPanel:AddControl( "TextBox", { Label = "#AIMName", 		Command = "cl_aim", 		WaitForEnter = "1" }  )
	CPanel:AddControl( "TextBox", { Label = "#MSNName", 		Command = "cl_msn", 		WaitForEnter = "1" }  )
	CPanel:AddControl( "TextBox", { Label = "#GTalkName", 		Command = "cl_gtalk", 		WaitForEnter = "1" }  )
	CPanel:AddControl( "TextBox", { Label = "#XFireName", 		Command = "cl_xfire", 		WaitForEnter = "1" }  )
	
	CPanel:AddControl( "Slider", { Label = "#Screenshot Quality",	Type = "Integer", 	Command = "jpeg_quality", 	Min = "0", 		Max = "100" }  )
	CPanel:AddControl( "Slider", { Label = "#Mouse Sensitivity",	Type = "Float", 	Command = "sensitivity", 	Min = "1", 		Max = "15" }  )
	
	CPanel:AddControl( "CheckBox", { Label = "#ShowHints", 		Command = "cl_showhints" }  )
	
end


local function PerformanceOptions( CPanel )

	CPanel:AddControl( "Header", { Text = "#Performance Tweaks" }  )
	
	CPanel:AddControl( "Slider", 	{ Label = "#Max Decals",	Type = "Integer", 	Command = "r_decals", 	Min = "0", 		Max = "4096" }  )
	CPanel:AddControl( "Slider", 	{ Label = "#Model LOD",	Type = "Integer", 	Command = "r_lod", 	Min = "-1", 	Max = "5" }  )
	
	CPanel:AddControl( "CheckBox", 	{ Label = "#Shadows",	Command = "r_shadows" }  )	
	
	CPanel:AddControl( "CheckBox", 	{ Label = "#DrawDetailProps", 	Command = "r_drawdetailprops" }  )	
	CPanel:AddControl( "Slider", 	{ Label = "#DetailDistance",	Type = "Integer", 	Command = "cl_detaildist", 	Min = "64", 	Max = "4096" }  )
	
	/*
	
	"ComboBox"
	{
		"Label"				"#Texture_Quality"
		"MenuButton"		"0"
		
		"Options"
		{
			"#Highest"
			{
				"mat_picmip"			"0"
			}
			
			"#Medium"
			{
				"mat_picmip"			"2"
			}
			
			"#Low"
			{
				"mat_picmip"			"4"
			}
		}
		
		"CVars" 
		{
			"0"	"mat_picmip"					
		}
	}
	
	*/
	

end

local function HideOptions( CPanel )

	CPanel:AddControl( "Header", { Text = "#Hide Options" }  )

	CPanel:AddControl( "CheckBox", { Label = "#DrawThrusterEffects", 	Command = "cl_drawthrusterseffects" }  )
	CPanel:AddControl( "CheckBox", { Label = "#DrawHoverBalls", 		Command = "cl_drawhoverballs" }  )
	CPanel:AddControl( "CheckBox", { Label = "#DrawCameras", 			Command = "cl_drawcameras" }  )
	CPanel:AddControl( "CheckBox", { Label = "#DrawPhysgunBeams", 		Command = "physgun_drawbeams" }  )

end

local function VisualOptions( CPanel )

	CPanel:AddControl( "Header", { Text = "#Visual Tweaks" }  )

	CPanel:AddControl( "Slider", { Label = "#Net Graph",	Type = "Integer", 	Command = "net_graph", 		Min = "0", 		Max = "3" }  )
	CPanel:AddControl( "Slider", { Label = "#Show FPS",		Type = "Integer", 	Command = "cl_showfps", 	Min = "0", 		Max = "2" }  )

	CPanel:AddControl( "CheckBox", { Label = "#Show_Low_Res_Textures",	Command = "mat_showlowresimage" }  )	
	CPanel:AddControl( "CheckBox", { Label = "#Wireframe",				Command = "mat_wireframe" }  )	

end
	
local function FogOptions( CPanel )

	CPanel:AddControl( "Header", { Text = "#Fog Options" }  )
	
	local params = { Label = "#Fog_Presets", MenuButton = "1", Folder = "fog", Options = {}, CVars = {} }
	
	params.Options[ "#Default" ] = {	fog_start =				"-1",
								fog_startskybox =		"-1",
								fog_end =				"-1",
								fog_endskybox =			"-1",
								fog_color =				"255 255 255",
								fog_colorskybox =		"255 255 255" }
								
	params.CVars = { "fog_start",
						"fog_startskybox",
						"fog_end",
						"fog_endskybox",
						"fog_color",
						"fog_colorskybox"	}
	
	CPanel:AddControl( "ComboBox", params )
	
	CPanel:AddControl( "CheckBox", { Label = "#Fog_Override",	Command = "fog_override" }  )	
	CPanel:AddControl( "Slider", { Label = "#Fog_Start", Type = "Float", Command = "fog_start", Command2 = "fog_startskybox", Min = "0", Max = "10000" }  )
	CPanel:AddControl( "Slider", { Label = "#Fog_End", Type = "Float", Command = "fog_end", Command2 = "fog_endskybox", Min = "0", Max = "10000" }  )
	CPanel:AddControl( "Color", { Label = "#Fog_Color", RGB = "fog_color", RGB2 = "fog_colorskybox", ShowAlpha = "0", ShowHSV = "1", ShowRGB = "1", Multiplier = "255" }  )

end
	
/*
// Tool Menu
*/
local function PopulateOptionMenus()

	spawnmenu.AddToolMenuOption( "Options", "Player", "Settings", "#Settings", "", "", PlayerSettings )
	spawnmenu.AddToolMenuOption( "Options", "Player", "Model", "#Model", "", "", PlayerModel )
	
	
	
	spawnmenu.AddToolMenuOption( "Options", "Performance", "Tweaks", "#Tweaks", "", "", PerformanceOptions )
	
	spawnmenu.AddToolMenuOption( "Options", "Visuals", 	"Tweaks",	"#Hiding", 	"", "", HideOptions )
	spawnmenu.AddToolMenuOption( "Options", "Visuals", 	"Tweaks", 	"#Tweaks", 	"", "", VisualOptions )
	spawnmenu.AddToolMenuOption( "Options", "Visuals", 	"Fog", 		"#Fog", 	"", "", FogOptions )

end

hook.Add( "PopulateToolMenu", "PopulateOptionMenus", PopulateOptionMenus )

/* 
// Categories
*/
local function CreateOptionsCategories()

	spawnmenu.AddToolCategory( "Options", 	"Player", 		"#Player" )
	spawnmenu.AddToolCategory( "Options", 	"Performance", 	"#Performance" )
	spawnmenu.AddToolCategory( "Options", 	"Visuals", 		"#Visuals" )

end	

hook.Add( "AddToolMenuCategories", "CreateOptionsCategories", CreateOptionsCategories )