--modified
--special for Onirica developing

--cl_display_hud = 1
--ThirdPersonView = 0

Input:BindCommandToKey("#GotoNextSpawnpoint()","f2",1);
Input:BindCommandToKey("#ToggleNewDesignerMode(40,120,1)","f3",1);
Input:BindCommandToKey("#ToggleNewDesignerMode(10,15,0)","f4",1);
Input:BindCommandToKey("#UseJoypad()","f5",1);
Input:BindCommandToKey("#ToggleSound()","f6",1);
Input:BindCommandToKey("#ToggleDisplayInfo()","f8",1);
Input:BindCommandToKey("#ToggleWireframeMode()","f9",1);

--not important one, but hey
Input:BindCommandToKey("#ToggleAIInfo()","f11",1);

function ToggleAIInfo()
	
	if (not aiinfo) then
		aiinfo=1;
	else
		aiinfo=1-aiinfo;
	end

	if (aiinfo==1) then
		ai_debugdraw=1;
		ai_drawplayernode=1;
		ai_area_info=1;
	else
		ai_debugdraw=0;
		ai_drawplayernode=0;
		ai_area_info=0;
	end
end

function GotoNextSpawnpoint()

	Hud:AddMessage("[DEV]: Next spawn point");

	local pt;
	pt=Server:GetNextRespawnPoint();

	if(not pt)then 												-- last respawn point or there are no respawn points
		pt=Server:GetFirstRespawnPoint();		-- try to get the first one
	end

	if(pt)then 														-- if there is one
		Game:ForceEntitiesToSleep();

		_localplayer:SetPos(pt);
		_localplayer:SetAngles({ x = pt.xA, y = pt.yA, z = pt.zA });
	end
end

function ToggleNewDesignerMode( speedwalk, speedrun, withcollide )

	if(SuperDesignerMode_Save1~=nil or speedwalk==nil) then
		Hud:AddMessage("[DEV]: Designer fly mode OFF");

 		p_speed_walk = SuperDesignerMode_Save1;
		p_speed_run = SuperDesignerMode_Save2;
		_localplayer.DynProp.gravity = SuperDesignerMode_Save3;
		_localplayer.DynProp.inertia = SuperDesignerMode_Save4;
		_localplayer.DynProp.swimming_gravity = SuperDesignerMode_Save5;
		_localplayer.DynProp.swimming_inertia = SuperDesignerMode_Save6;
		_localplayer.DynProp.air_control = SuperDesignerMode_Save7;
		_localplayer.cnt:SetDynamicsProperties( _localplayer.DynProp );
		SuperDesignerMode_Save1=nil;

		-- activate collision, parameter is 0 or 1
		_localplayer:ActivatePhysics(1);

	else
		Hud:AddMessage("[DEV]: Designer fly mode ON");

 		SuperDesignerMode_Save1 = p_speed_walk;
		SuperDesignerMode_Save2 = p_speed_run;
		SuperDesignerMode_Save3 = _localplayer.DynProp.gravity;
		SuperDesignerMode_Save4 = _localplayer.DynProp.inertia;
		SuperDesignerMode_Save5 = _localplayer.DynProp.swimming_gravity;
		SuperDesignerMode_Save6 = _localplayer.DynProp.swimming_inertia;
		SuperDesignerMode_Save7 = _localplayer.DynProp.air_control;

		p_speed_walk = speedwalk;
		p_speed_run = speedrun;
		_localplayer.DynProp.gravity=0.0;
		_localplayer.DynProp.inertia=0.0;
		_localplayer.DynProp.swimming_gravity=0.0;
		_localplayer.DynProp.swimming_inertia=0.0;
		_localplayer.DynProp.air_control=1.0;
		_localplayer.cnt:SetDynamicsProperties( _localplayer.DynProp );

		-- deactivate collision, parameter is 0 or 1
		_localplayer:ActivatePhysics(withcollide);
	end
end

function UseJoypad()
		if (tonumber(cl_use_joypad)>0) then
		cl_use_joypad=0;
		Hud:AddMessage("[DEV]: Joypad Mode Off");
	else 
		cl_use_joypad=1;
		Hud:AddMessage("[DEV]: Joypad Mode On");
	end 
end

function ToggleSound()
		if (tonumber(s_SoundEnable)>0) then
		s_SoundEnable=0;
		Hud:AddMessage("[DEV]: Sound Off");
	else 
		s_SoundEnable=1;
		Hud:AddMessage("[DEV]: Sound On");
	end 
end

function ToggleDisplayInfo()
		if (tonumber(r_DisplayInfo)>0) then
		r_DisplayInfo=0;
		Hud:AddMessage("[DEV]: Display Info Off");
	else 
		r_DisplayInfo=1;
		Hud:AddMessage("[DEV]: Display Info On");
	end 
end

function ToggleWireframeMode()
		if (tonumber(r_PolygonMode)>1) then
		r_PolygonMode=1;
		Hud:AddMessage("[DEV]: Wireframe mode Off");
	else 
		r_PolygonMode=2;
		Hud:AddMessage("[DEV]: Wireframe mode On");
	end 
end