/*
Copyright (C) 2000	LordHavoc, Ender

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/
// nehahra.c
#include "quakedef.h"

#ifdef GLQUAKE
int	NehGameType = 0;

cvar_t	gl_notrans	= {"gl_notrans", "0"};
float	model_alpha;

cvar_t	oldsky		= {"r_oldsky", "1"};
char	prev_skybox[64];

cvar_t	nospr32		= {"nospr32", "0"};

// cutscene demo usage
cvar_t  nehx00		= {"nehx00", "0"};
cvar_t	nehx01		= {"nehx01", "0"};
cvar_t  nehx02		= {"nehx02", "0"};
cvar_t	nehx03		= {"nehx03", "0"};
cvar_t  nehx04		= {"nehx04", "0"};
cvar_t	nehx05		= {"nehx05", "0"};
cvar_t  nehx06		= {"nehx06", "0"};
cvar_t	nehx07		= {"nehx07", "0"};
cvar_t  nehx08		= {"nehx08", "0"};
cvar_t	nehx09		= {"nehx09", "0"};
cvar_t  nehx10		= {"nehx10", "0"};
cvar_t	nehx11		= {"nehx11", "0"};
cvar_t  nehx12		= {"nehx12", "0"};
cvar_t	nehx13		= {"nehx13", "0"};
cvar_t  nehx14		= {"nehx14", "0"};
cvar_t	nehx15		= {"nehx15", "0"};
cvar_t  nehx16		= {"nehx16", "0"};
cvar_t	nehx17		= {"nehx17", "0"};
cvar_t  nehx18		= {"nehx18", "0"};
cvar_t	nehx19		= {"nehx19", "0"};
cvar_t  cutscene	= {"cutscene", "1"};

void CheckMode (void)
{
	int			h = 4, h2 = 5;
	qboolean	movieinstalled = false, gameinstalled = false;

	Con_SafePrintf ("Beginning Nehahra check...\n");

// Check for movies
	if (COM_FindFile("hearing.dem") || COM_FindFile("hearing.dz"))
		movieinstalled = true;

	Con_SafePrintf ("Found Movie...\n");

// Check for game
	if (COM_FindFile("maps/neh1m4.bsp"))
	{
		gameinstalled = true;
	}
	Con_SafePrintf ("Found Game...\n");

	if (gameinstalled && movieinstalled)
	{
		NehGameType = TYPE_BOTH;             // mainmenu.lmp
		Con_SafePrintf ("Running Both Movie and Game\n");
		return;
	}

	if (gameinstalled && !movieinstalled)
	{
		NehGameType = TYPE_GAME;             // gamemenu.lmp
		Con_SafePrintf ("Running Game Nehahra\n");
		return;
	}

	if (!gameinstalled && movieinstalled)
	{
		NehGameType = TYPE_DEMO;             // demomenu.lmp
		Con_SafePrintf ("Running Movie Nehahra\n");
		return;
	}

	Host_Error ("You must specify the Nehahra game directory in -game!");
}

void Neh_DoBindings (void)
{
	if (NehGameType == TYPE_DEMO)
	{
		Cbuf_AddText ("bind F1 \"cl_demospeed 0.4\"\n");
		Cbuf_AddText ("bind F2 \"cl_demospeed 0.6\"\n");
		Cbuf_AddText ("bind F3 \"cl_demospeed 0.8\"\n");
		Cbuf_AddText ("bind F4 \"cl_demospeed 1.0\"\n");
		Cbuf_AddText ("bind F5 \"cl_demospeed 1.4\"\n");
		Cbuf_AddText ("bind F6 \"cl_demospeed 1.6\"\n");
		Cbuf_AddText ("bind F7 \"cl_demospeed 1.8\"\n");
		Cbuf_AddText ("bind F8 \"cl_demospeed 2.0\"\n");
		Cbuf_AddText ("bind F9 \"cl_demospeed 2.4\"\n");
		Cbuf_AddText ("bind F10 \"cl_demospeed 2.6\"\n");

		Cbuf_AddText ("bind PAUSE pausedemo\n");
	}
}

void Neh_Init (void)
{
	Cvar_RegisterVariable (&gl_notrans);
	Cvar_RegisterVariable (&oldsky);
	Cvar_RegisterVariable (&nospr32);

	// Nehahra uses these to pass data around cutscene demos
	Cvar_RegisterVariable (&nehx00);
	Cvar_RegisterVariable (&nehx01);
	Cvar_RegisterVariable (&nehx02);
	Cvar_RegisterVariable (&nehx03);
	Cvar_RegisterVariable (&nehx04);
	Cvar_RegisterVariable (&nehx05);
	Cvar_RegisterVariable (&nehx06);
	Cvar_RegisterVariable (&nehx07);
	Cvar_RegisterVariable (&nehx08);
	Cvar_RegisterVariable (&nehx09);
	Cvar_RegisterVariable (&nehx10);
	Cvar_RegisterVariable (&nehx11);
	Cvar_RegisterVariable (&nehx12);
	Cvar_RegisterVariable (&nehx13);
	Cvar_RegisterVariable (&nehx14);
	Cvar_RegisterVariable (&nehx15);
	Cvar_RegisterVariable (&nehx16);
	Cvar_RegisterVariable (&nehx17);
	Cvar_RegisterVariable (&nehx18);
	Cvar_RegisterVariable (&nehx19);
	Cvar_RegisterVariable (&cutscene);

	Cvar_Set ("gl_hwblend", "0");

	Cmd_AddLegacyCommand ("pausedemo", "pause");

	CheckMode ();

	if (COM_CheckParm("-matrox")) {
		nospr32.value = 1;
	}
	MOD_init ();
}
#endif



