Beispiel #1
0
static void Preferences_Event(void* ptr, int notification) {
    if (notification != QM_ACTIVATED) {
        return;
    }

    switch (((menucommon_s*)ptr)->id) {
        case ID_CROSSHAIR:
            trap_Cvar_SetValue("cg_drawCrosshair", s_preferences.crosshair.curvalue);
            break;

        case ID_SIMPLEITEMS:
            trap_Cvar_SetValue("cg_simpleItems", s_preferences.simpleitems.curvalue);
            break;

        case ID_HIGHQUALITYSKY:
            trap_Cvar_SetValue("r_fastsky", !s_preferences.highqualitysky.curvalue);
            break;

        case ID_EJECTINGBRASS:
            if (s_preferences.brass.curvalue)
                trap_Cvar_Reset("cg_brassTime");
            else
                trap_Cvar_SetValue("cg_brassTime", 0);
            break;

        case ID_WALLMARKS:
            trap_Cvar_SetValue("cg_marks", s_preferences.wallmarks.curvalue);
            break;

        case ID_DYNAMICLIGHTS:
            trap_Cvar_SetValue("r_dynamiclight", s_preferences.dynamiclights.curvalue);
            break;

        case ID_IDENTIFYTARGET:
            trap_Cvar_SetValue("cg_drawCrosshairNames", s_preferences.identifytarget.curvalue);
            break;

        case ID_SYNCEVERYFRAME:
            trap_Cvar_SetValue("r_finish", s_preferences.synceveryframe.curvalue);
            break;

        case ID_FORCEMODEL:
            trap_Cvar_SetValue("cg_forcemodel", s_preferences.forcemodel.curvalue);
            break;

        case ID_DRAWTEAMOVERLAY:
            trap_Cvar_SetValue("cg_drawTeamOverlay", s_preferences.drawteamoverlay.curvalue);
            break;

        case ID_ALLOWDOWNLOAD:
            trap_Cvar_SetValue("cl_allowDownload", s_preferences.allowdownload.curvalue);
            trap_Cvar_SetValue("sv_allowDownload", s_preferences.allowdownload.curvalue);
            break;

        case ID_BACK:
            UI_PopMenu();
            break;
    }
}
/*
=================
Controls_InitCvars
=================
*/
static void Controls_InitCvars( void )
{
	int				i;
	configcvar_t*	cvarptr;

	cvarptr = g_configcvars;
	for (i=0; ;i++,cvarptr++)
	{
		if (!cvarptr->name)
			break;

		// get current value
		cvarptr->value = trap_Cvar_VariableValue( cvarptr->name );

		// get default value
		trap_Cvar_Reset( cvarptr->name );
		cvarptr->defaultvalue = trap_Cvar_VariableValue( cvarptr->name );

		// restore current value
		trap_Cvar_SetValue( cvarptr->name, cvarptr->value );
	}
}
static void Preferences_Event( void* ptr, int notification ) {
	if( notification != QM_ACTIVATED ) {
		return;
	}

	switch( ((menucommon_s*)ptr)->id ) {
#ifndef TURTLEARENA
	case ID_CROSSHAIR:
		trap_Cvar_SetValue( "cg_drawCrosshair", s_preferences.crosshair.curvalue );
		break;

	case ID_CROSSHAIRHEALTH:
		trap_Cvar_SetValue( "cg_crosshairHealth", s_preferences.crosshairhealth.curvalue );
		break;

	case ID_VIEWBOB:
		trap_Cvar_SetValue( "cg_viewbob", s_preferences.viewbob.curvalue );
		break;
#endif

	case ID_SIMPLEITEMS:
		trap_Cvar_SetValue( "cg_simpleItems", s_preferences.simpleitems.curvalue );
		break;

	case ID_HIGHQUALITYSKY:
		trap_Cvar_SetValue( "r_fastsky", !s_preferences.highqualitysky.curvalue );
		break;

#ifndef TURTLEARENA
	case ID_EJECTINGBRASS:
		if ( s_preferences.brass.curvalue )
			trap_Cvar_Reset( "cg_brassTime" );
		else
			trap_Cvar_SetValue( "cg_brassTime", 0 );
		break;
#endif

	case ID_WALLMARKS:
		trap_Cvar_SetValue( "cg_marks", s_preferences.wallmarks.curvalue );
		break;

	case ID_DYNAMICLIGHTS:
		trap_Cvar_SetValue( "r_dynamiclight", s_preferences.dynamiclights.curvalue );
		break;		

	case ID_IDENTIFYTARGET:
		trap_Cvar_SetValue( "cg_drawCrosshairNames", s_preferences.identifytarget.curvalue );
		break;

	case ID_SYNCEVERYFRAME:
		trap_Cvar_SetValue( "r_finish", s_preferences.synceveryframe.curvalue );
		break;

	case ID_FORCEMODEL:
#ifdef TURTLEARENA // NO_CGFORCEMODLE
		trap_Cvar_SetValue( "cg_deferPlayers", s_preferences.forcemodel.curvalue );
#else
		trap_Cvar_SetValue( "cg_forcemodel", s_preferences.forcemodel.curvalue );
#endif
		break;

	case ID_DRAWTEAMOVERLAY:
		trap_Cvar_SetValue( "cg_drawTeamOverlay", s_preferences.drawteamoverlay.curvalue );
		break;

	case ID_ALLOWDOWNLOAD:
		trap_Cvar_SetValue( "cl_allowDownload", s_preferences.allowdownload.curvalue );
		trap_Cvar_SetValue( "sv_allowDownload", s_preferences.allowdownload.curvalue );
		break;

	case ID_SPLITVERTICAL:
		trap_Cvar_SetValue( "cg_splitviewVertical", s_preferences.splitvertical.curvalue );
		break;

	case ID_SPLITTEXTSIZE:
		trap_Cvar_SetValue( "cg_splitviewTextScale", 1.0f + (float)s_preferences.splittextsize.curvalue/2.0f );
		break;

	case ID_THIRDSIZE:
		trap_Cvar_SetValue( "cg_splitviewThirdEqual", s_preferences.thirdsize.curvalue );
		break;

#ifdef IOQ3ZTM // CONTENT_FILTERING
#ifndef NOBLOOD
	case ID_SHOWBLOOD:
		trap_Cvar_SetValue( "com_blood", s_preferences.showblood.curvalue );
		break;
#endif
#ifndef NOTRATEDM
	case ID_SHOWGIBS:
		trap_Cvar_SetValue( "cg_gibs", s_preferences.showgibs.curvalue );
		break;
#endif
#endif

	case ID_BACK:
		UI_PopMenu();
		break;
	}
}
/*
=================
GraphicsOptions_ApplyChanges
=================
*/
static void GraphicsOptions_ApplyChanges( void *unused, int notification )
{
	if (notification != QM_ACTIVATED)
		return;

	switch ( s_graphicsoptions.texturebits.curvalue  )
	{
	case 0:
		trap_Cvar_SetValue( "r_texturebits", 0 );
		break;
	case 1:
		trap_Cvar_SetValue( "r_texturebits", 16 );
		break;
	case 2:
		trap_Cvar_SetValue( "r_texturebits", 32 );
		break;
	}
	trap_Cvar_SetValue( "r_picmip", 3 - s_graphicsoptions.tq.curvalue );

	if( resolutionsDetected )
	{
		// search for builtin mode that matches the detected mode
		int mode;
		if ( s_graphicsoptions.mode.curvalue == -1
			|| s_graphicsoptions.mode.curvalue >= ARRAY_LEN( detectedResolutions ) )
			s_graphicsoptions.mode.curvalue = 0;

		mode = GraphicsOptions_FindBuiltinResolution( s_graphicsoptions.mode.curvalue );
		if( mode == -1 )
		{
			char w[ 16 ], h[ 16 ];
			Q_strncpyz( w, detectedResolutions[ s_graphicsoptions.mode.curvalue ], sizeof( w ) );
			*strchr( w, 'x' ) = 0;
			Q_strncpyz( h,
					strchr( detectedResolutions[ s_graphicsoptions.mode.curvalue ], 'x' ) + 1, sizeof( h ) );
			trap_Cvar_Set( "r_customwidth", w );
			trap_Cvar_Set( "r_customheight", h );
		}

		trap_Cvar_SetValue( "r_mode", mode );
	}
	else
		trap_Cvar_SetValue( "r_mode", s_graphicsoptions.mode.curvalue );

	trap_Cvar_SetValue( "r_fullscreen", s_graphicsoptions.fs.curvalue );

	trap_Cvar_Reset("r_colorbits");
	trap_Cvar_Reset("r_depthbits");
	trap_Cvar_Reset("r_stencilbits");

	trap_Cvar_SetValue( "r_vertexLight", s_graphicsoptions.lighting.curvalue );
	trap_Cvar_SetValue( "r_flares", s_graphicsoptions.flares.curvalue );

	if ( s_graphicsoptions.geometry.curvalue == 3 )
	{
		trap_Cvar_SetValue( "r_lodBias", -2 );
		trap_Cvar_SetValue( "r_subdivisions", 4 );
	}
	else if ( s_graphicsoptions.geometry.curvalue == 2 )
	{
		trap_Cvar_SetValue( "r_lodBias", 0 );
		trap_Cvar_SetValue( "r_subdivisions", 4 );
	}
	else if ( s_graphicsoptions.geometry.curvalue == 1 )
	{
		trap_Cvar_SetValue( "r_lodBias", 1 );
		trap_Cvar_SetValue( "r_subdivisions", 12 );
	}
	else
	{
		trap_Cvar_SetValue( "r_lodBias", 1 );
		trap_Cvar_SetValue( "r_subdivisions", 20 );
	}

	if ( s_graphicsoptions.filter.curvalue >= 2 )
	{
		trap_Cvar_SetValue( "r_ext_texture_filter_anisotropic", 1 );

		switch ( s_graphicsoptions.filter.curvalue )
		{
			default:
			case 2:
				trap_Cvar_SetValue( "r_ext_max_anisotropy", 2 );
				break;
			case 3:
				trap_Cvar_SetValue( "r_ext_max_anisotropy", 4 );
				break;
			case 4:
				trap_Cvar_SetValue( "r_ext_max_anisotropy", 8 );
				break;
			case 5:
				trap_Cvar_SetValue( "r_ext_max_anisotropy", 16 );
				break;
		}
	}
	else
	{
		trap_Cvar_SetValue( "r_ext_texture_filter_anisotropic", 0 );

		if ( s_graphicsoptions.filter.curvalue )
		{
			trap_Cvar_Set( "r_textureMode", "GL_LINEAR_MIPMAP_LINEAR" );
		}
		else
		{
			trap_Cvar_Set( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST" );
		}
	}

	trap_Cvar_SetValue( "r_ext_multisample", s_graphicsoptions.multisample.curvalue * 2 );

	trap_Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" );
}