Exemple #1
0
void __CmdFunc_Append()
{
	if (gEngfuncs.Cmd_Argc() != 2) {
		if (!gEngfuncs.pDemoAPI->IsPlayingback())
			gEngfuncs.Con_Printf("append <command> - put the command into the end of the command buffer.\n");

		return;
	}

	EngineClientCmd(gEngfuncs.Cmd_Argv(1));
}
Exemple #2
0
void CHudAmmo::UserCmd_Close(void)
{
	if ( m_pActiveSel )
	{
		m_pLastSel = m_pActiveSel;
		m_pActiveSel = nullptr;
		PlaySound("common/wpn_hudoff.wav", 1);
	}
	else
		EngineClientCmd("escape");
}
Exemple #3
0
void Bench_CheckStart( void )
{
	const char *level;
	if ( !started && !Bench_Active() )
	{
		level = gEngfuncs.pfnGetLevelName();
		if ( level && level[0] && !stricmp( level, "maps/ppdemo.bsp" ) )
		{
			started = 1;
			EngineClientCmd( "ppdemostart\n" );
		}
	}
}
Exemple #4
0
// selects an item from the menu
void CHudMenu :: SelectMenuItem( int menu_item )
{
	// if menu_item is in a valid slot,  send a menuselect command to the server
	if ( (menu_item > 0) && (m_bitsValidSlots & (1 << (menu_item-1))) )
	{
		char szbuf[32];
		sprintf( szbuf, "menuselect %d\n", menu_item );
		EngineClientCmd( szbuf );

		// remove the menu
		m_fMenuDisplayed = 0;
		m_iFlags &= ~HUD_ACTIVE;
	}
}
Exemple #5
0
// This is called every time the DLL is loaded
void CHud :: Init( void )
{
	HOOK_MESSAGE( Logo );
	HOOK_MESSAGE( ResetHUD );
	HOOK_MESSAGE( GameMode );
	HOOK_MESSAGE( InitHUD );
	HOOK_MESSAGE( ViewMode );
	HOOK_MESSAGE( SetFOV );
	HOOK_MESSAGE( Concuss );

	HOOK_MESSAGE( Gametype );

	// TFFree CommandMenu
	HOOK_COMMAND( "+commandmenu", OpenCommandMenu );
	HOOK_COMMAND( "-commandmenu", CloseCommandMenu );
	HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu );
	HOOK_COMMAND( "special", InputPlayerSpecial );
	HOOK_COMMAND( "togglebrowser", ToggleServerBrowser );

	HOOK_COMMAND( "agrecord", Agrecord );
	HOOK_COMMAND( "append", Append );
	EngineClientCmd("alias zpecial \"append _zpecial\"");

	force_model::hook_commands();
	steam_id::hook_messages();

	HOOK_MESSAGE( ValClass );
	HOOK_MESSAGE( TeamNames );
	HOOK_MESSAGE( Feign );
	HOOK_MESSAGE( Detpack );
	HOOK_MESSAGE( MOTD );
	HOOK_MESSAGE( BuildSt );
	HOOK_MESSAGE( RandomPC );
	HOOK_MESSAGE( ServerName );
	HOOK_MESSAGE( ScoreInfo );
	HOOK_MESSAGE( TeamScore );
	HOOK_MESSAGE( TeamInfo );

	HOOK_MESSAGE( Spectator );
	HOOK_MESSAGE( AllowSpec );
	
	HOOK_MESSAGE( SpecFade );
	HOOK_MESSAGE( ResetFade );

	// VGUI Menus
	HOOK_MESSAGE( VGUIMenu );

	HOOK_MESSAGE( CheatCheck );
	HOOK_MESSAGE( WhString );
	HOOK_MESSAGE( SpikeCheck );
	HOOK_MESSAGE( CRC32 );
	HOOK_MESSAGE( PlaySound );

	CVAR_CREATE( "hud_classautokill", "1", FCVAR_ARCHIVE | FCVAR_USERINFO );		// controls whether or not to suicide immediately on TF class switch
	CVAR_CREATE( "hud_takesshots", "0", FCVAR_ARCHIVE );		// controls whether or not to automatically take screenshots at the end of a round

	// Implemented server-side, needs to be registered client-side.
	CVAR_CREATE( "cl_autowepswitch", "1", FCVAR_ARCHIVE | FCVAR_USERINFO | FCVAR_CLIENTDLL );

	// This has to be called cl_righthand (there's some stuff compiled into the engine),
	// and also from my tests it has to be 0 for normal and 1 for left-handed.
	cl_righthand = CVAR_CREATE( "cl_righthand", "0", FCVAR_ARCHIVE );

	m_iLogo = 0;
	m_iFOV = 0;

	CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 );
	default_fov = CVAR_CREATE( "default_fov", "90", 0 );
	m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
	m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );
	m_pCvarDrawDeathNoticesAlways = CVAR_CREATE( "cl_draw_deathnotices_always", "0", FCVAR_ARCHIVE );
	m_pCvarColor = CVAR_CREATE( "hud_color", "", FCVAR_ARCHIVE );
	cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );

	m_pSpriteList = NULL;

	// Clear any old HUD list
	if ( m_pHudList )
	{
		HUDLIST *pList;
		while ( m_pHudList )
		{
			pList = m_pHudList;
			m_pHudList = m_pHudList->pNext;
			free( pList );
		}
		m_pHudList = NULL;
	}

	// In case we get messages before the first update -- time will be valid
	m_flTime = 1.0;

	m_Ammo.Init();
	m_Health.Init();
	m_SayText.Init();
	m_Spectator.Init();
	m_Geiger.Init();
	m_Train.Init();
	m_Battery.Init();
	m_Flash.Init();
	m_Message.Init();
	m_StatusBar.Init();
	m_DeathNotice.Init();
	m_AmmoSecondary.Init();
	m_TextMessage.Init();
	m_StatusIcons.Init();
	m_Countdown.Init();
	m_Crosshairs.Init();
	m_CTF.Init();
	m_Debug.Init();
	m_Location.Init();
	m_NextMap.Init();
	m_PlayerId.Init();
	m_Scores.Init();
	m_Settings.Init();
	m_Speedometer.Init();
	m_SuddenDeath.Init();
	m_Timeout.Init();
	m_Timer.Init();
	m_Vote.Init();
	m_Watermark.Init();
	GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);

	m_Menu.Init();
	
	ServersInit();

	MsgFunc_ResetHUD(0, 0, NULL );
}
Exemple #6
0
void CHudBenchmark::Think( void )
{
	if ( !Bench_Active() )
		return;

	Trace_Think();

	if ( started )
	{
		started = 0;

		// Clear variable
		m_fReceiveTime = 0.0;
		m_nFPSCount = 0;
		m_fAverageFT = 0.0;
		m_nSentFinish = 0;
		m_StoredLatency = 0.0;
		m_StoredPacketLoss = 0.0;
		m_nStoredHopCount = 0;
		m_nTraceDone = 0;
		m_nObjects = 0;
		m_nScoreComputed = 0;
		m_nCompositeScore = 0;
		m_fAvgScore = 0;
		m_fDrawScore = 0.0;
		m_fAvgFrameRate = 0.0;
	}

	if ( gHUD.m_flTime > g_benchSwitchTime )
	{
		Bench_SetStage( Bench_GetStage() + 1 );
		StartNextSection( Bench_GetStage() );
	}

	if ( Bench_InStage( FIRST_STAGE ) )
	{
		// Assume 1000 ms lag is the max and that would take all but 2 seconds of this interval to traverse
		if ( m_fReceiveTime )
		{
			float latency = 2.0 * m_StoredLatency;
			float switch_time;
			float total_time;
			
			latency = max( 0.0f, latency );
			latency = min( 1.0f, latency );

			total_time = Bench_GetSwitchTime();
			total_time -= 2.0;

			switch_time = m_fStageStarted + latency * total_time;
			switch_time += 1.0;

			if ( gHUD.m_flTime >= switch_time )
			{
				if ( !m_nSentFinish )
				{
					g_benchSwitchTime = gHUD.m_flTime + 1.0 + SCORE_TIME_UP;

					ServerCmd( "ppdemo 1 finish\n" );
					m_nSentFinish = 1;
				}
			}
			else
			{
				g_benchSwitchTime = gHUD.m_flTime + 10.0;
			}
		}
	}

	if ( Bench_InStage( SECOND_STAGE ) )
	{
		// frametime
		static float lasttime;
		float elapsed;
		float total;
		float frac;
		float switch_time;	// added by minman

		if ( lasttime )
		{
			float dt;

			dt = gHUD.m_flTime - lasttime;
			if ( dt > 0 )
			{
				CountFrame( dt );
			}
		}
		lasttime = gHUD.m_flTime;

		elapsed = gHUD.m_flTime - m_fStageStarted;
		total = Bench_GetSwitchTime();
		if ( total )
		{
			frac = elapsed / total;

			// Only takes 1/2 time to get up to maximum speed
			frac *= 2.0;
			frac = max( 0.0f, frac );
			frac = min( 1.0f, frac );

			m_nObjects = (int)(NUM_BENCH_OBJ * frac);
		}
		switch_time = m_fStageStarted + total;

		/* BELOW ADDED BY minman */
		if (gHUD.m_flTime >= switch_time)
		{
			if ( !m_nSentFinish)
			{
				g_benchSwitchTime = gHUD.m_flTime + SCORE_TIME_UP;
				m_nSentFinish = 1;
			}
		}
		else
			g_benchSwitchTime = gHUD.m_flTime + 10.0;
	}

	/* BELOW ADDED BY minman */
	if ( Bench_InStage (THIRD_STAGE))
	{
		float switch_time = m_fStageStarted + Bench_GetSwitchTime();

		if (gHUD.m_flTime >= switch_time)
		{
			if ( !m_nSentFinish)
			{
				g_benchSwitchTime = gHUD.m_flTime + SCORE_TIME_UP;
				m_nSentFinish = 1;
			}
		}
		else
			g_benchSwitchTime = gHUD.m_flTime + 10.0;
	}

	if ( Bench_InStage( FOURTH_STAGE ) )
	{
		if ( !m_nScoreComputed )
		{
			m_nScoreComputed = 1;
			gHUD.m_Benchmark.SetCompositeScore();
		}
	}

	if ( Bench_GetStage() > LAST_STAGE )
	{
		m_iFlags &= ~HUD_ACTIVE;
		EngineClientCmd( "quit\n" );
	}
}