void BlackBox_Record( const char *type, const char *pFormat, ... ) { static ConVarRef blackbox( "blackbox" ); if ( IsX360() ) return; if ( !blackbox.IsValid() || !blackbox.GetBool() ) return; int type_num; for ( type_num = 0; type_num < blackboxrecorder->GetTypeCount(); type_num++ ) { if ( !V_strcasecmp( blackboxrecorder->GetTypeName( type_num ), type ) ) break; } if ( type_num >= blackboxrecorder->GetTypeCount() ) { Msg( "Invalid blackbox type: %s\n", type ); return; } char szMessage[1024]; va_list marker; va_start( marker, pFormat); Q_vsnprintf( szMessage, sizeof( szMessage ), pFormat, marker); va_end( marker ); //Msg( "Record: %s: %s\n", type, szMessage ); blackboxrecorder->Record( type_num, szMessage ); }
//============================================================================= void LoadingProgress::ApplySchemeSettings( IScheme *pScheme ) { // will cause the controls to be instanced BaseClass::ApplySchemeSettings( pScheme ); SetPaintBackgroundEnabled( true ); // now have controls, can now do further initing m_bValid = true; // find or create pattern // purposely not freeing these, not worth the i/o hitch for something so small const char *pImageName = "vgui/loadingbar"; m_textureID_LoadingBar = vgui::surface()->DrawGetTextureId( pImageName ); if ( m_textureID_LoadingBar == -1 ) { m_textureID_LoadingBar = vgui::surface()->CreateNewTextureID(); vgui::surface()->DrawSetTextureFile( m_textureID_LoadingBar, pImageName, true, false ); } // find or create pattern // purposely not freeing these, not worth the i/o hitch for something so small pImageName = "vgui/loadingbar_bg"; m_textureID_LoadingBarBG = vgui::surface()->DrawGetTextureId( pImageName ); if ( m_textureID_LoadingBarBG == -1 ) { m_textureID_LoadingBarBG = vgui::surface()->CreateNewTextureID(); vgui::surface()->DrawSetTextureFile( m_textureID_LoadingBarBG, pImageName, true, false ); } // need to get the default image loaded now // find or create pattern // Purposely not freeing these, need this image to be resident always. We flip to // this image on a sign out during loading and cannot bring it into existence then. #if defined ( SUPPORT_DEFAULT_LOADING_POSTER ) if ( m_pDefaultPosterDataKV ) { static ConVarRef mat_xbox_iswidescreen( "mat_xbox_iswidescreen" ); bool bIsWidescreen = mat_xbox_iswidescreen.GetBool(); bool bFullscreenPoster = m_pDefaultPosterDataKV->GetBool( "fullscreen", false ); const char *pszPosterImage = ( bFullscreenPoster && bIsWidescreen ) ? m_pDefaultPosterDataKV->GetString( "posterImage_widescreen" ) : m_pDefaultPosterDataKV->GetString( "posterImage" ); // have to do this to mimic what the bowels of the scheme manager does with bitmaps bool bPrependVguiFix = V_strnicmp( pszPosterImage, "vgui", 4 ) != 0; CFmtStr sPosterImageFmt( "%s%s", ( bPrependVguiFix ? "vgui/" : "" ), pszPosterImage ); pszPosterImage = sPosterImageFmt; m_textureID_DefaultPosterImage = vgui::surface()->DrawGetTextureId( pszPosterImage ); if ( m_textureID_DefaultPosterImage == -1 ) { m_textureID_DefaultPosterImage = vgui::surface()->CreateNewTextureID(); vgui::surface()->DrawSetTextureFile( m_textureID_DefaultPosterImage, pszPosterImage, true, false ); } } #endif SetupControlStates(); }
void CHudMapFinishedDialog::OnThink() { BaseClass::OnThink(); static ConVarRef hvel("mom_hud_speedometer_hvel"); m_iVelocityType = hvel.GetBool(); m_pPlayReplayButton->SetVisible(!m_bIsGhost); m_pRunUploadStatus->SetVisible(!m_bIsGhost); m_pRunSaveStatus->SetVisible(!m_bIsGhost); CMOMSpectatorGUI *pPanel = dynamic_cast<CMOMSpectatorGUI*>(gViewPortInterface->FindPanelByName(PANEL_SPECGUI)); if (pPanel && pPanel->IsVisible()) SetMouseInputEnabled(pPanel->IsMouseInputEnabled()); }
void OnGameFrameStart() { g_MapzoneEdit.Update(); if (!g_Timer.GotCaughtCheating()) { ConVarRef cheatsRef = ConVarRef("sv_cheats"); if (cheatsRef.GetBool()) { g_Timer.SetCheating(true); g_Timer.Stop(false); } } }
void CReplayRenderer::RenderVideo() { #if _DEBUG static ConVarRef replay_fake_render( "replay_fake_render" ); if ( replay_fake_render.IsValid() && replay_fake_render.GetBool() ) return; #endif if ( !engine->IsInGame() ) return; if ( !m_LayoffResult.IsValid() ) return; CompositeAndLayoffFrame( m_nFrame++ ); }
//Check friendly fire rules to see if a player should be hit //Returns true if damage should be dealt, false if it should not bool CDHLProjectile::CheckFriendlyFire( CBaseEntity* pEnt ) { if ( DHLRules()->IsTeamplay() ) { if ( pEnt->IsPlayer() ) { CDHL_Player* pPlayer = ToDHLPlayer( pEnt ); if ( pPlayer && m_pShooter ) { if ( pPlayer->GetTeamNumber() == m_pShooter->GetTeamNumber() ) { static ConVarRef ffVar("mp_friendlyfire"); if ( ffVar.GetBool() ) return false; } } } } return true; }
//============================================================================= void LoadingProgress::SetupPoster( void ) { int i; bool bNamesVisible = false; vgui::ImagePanel *pPoster = dynamic_cast< vgui::ImagePanel* >( FindChildByName( "Poster" ) ); if ( pPoster ) { #if !defined( _X360 ) int screenWide, screenTall; surface()->GetScreenSize( screenWide, screenTall ); float aspectRatio = (float)screenWide/(float)screenTall; bool bIsWidescreen = aspectRatio >= 1.5999f; #else static ConVarRef mat_xbox_iswidescreen( "mat_xbox_iswidescreen" ); bool bIsWidescreen = mat_xbox_iswidescreen.GetBool(); #endif /* const char *pszPosterImage; int nChosenLoadingImage = RandomInt( 1, 4 ); switch( nChosenLoadingImage ) { case 1: pszPosterImage = ( m_bFullscreenPoster && bIsWidescreen ) ? "swarm/loading/BGFX01_wide" : "swarm/loading/BGFX01"; break; case 2: pszPosterImage = ( m_bFullscreenPoster && bIsWidescreen ) ? "swarm/loading/BGFX02_wide" : "swarm/loading/BGFX02"; break; case 3: pszPosterImage = ( m_bFullscreenPoster && bIsWidescreen ) ? "swarm/loading/BGFX03_wide" : "swarm/loading/BGFX03"; break; case 4: default: pszPosterImage = ( m_bFullscreenPoster && bIsWidescreen ) ? "swarm/loading/BGFX04_wide" : "swarm/loading/BGFX04"; break; }*/ char pszPosterImage[MAX_PATH]; V_snprintf( pszPosterImage, sizeof( pszPosterImage ), ( m_bFullscreenPoster && bIsWidescreen ) ? "../console/%s_widescreen" : "../console/%s", m_pChapterInfo->GetString( "map" ) ); // if the image was cached this will just hook it up, otherwise it will load it pPoster->SetImage( pszPosterImage ); if ( pPoster->GetImage() ) { bNamesVisible = true; } } bool bIsLocalized = false; #ifdef _X360 bIsLocalized = XBX_IsLocalized(); #else char uilanguage[ 64 ]; engine->GetUILanguage( uilanguage, sizeof( uilanguage ) ); if ( Q_stricmp( uilanguage, "english" ) ) { bIsLocalized = true; } #endif SetControlVisible( "LocalizedCampaignName", false ); SetControlVisible( "LocalizedCampaignTagline", false ); wchar_t szPlayerNames[MAX_PATH]; Q_memset( szPlayerNames, 0, sizeof( szPlayerNames ) ); int nNumNames = 0; for ( i=0;i<NUM_LOADING_CHARACTERS;i++ ) { if ( !m_PlayerNames[i] || !m_PlayerNames[i][0] ) { continue; } if ( nNumNames != 0 ) { wcsncat( szPlayerNames, L", ", sizeof( szPlayerNames ) ); } wchar_t szName[64]; if ( m_PlayerNames[i] && m_PlayerNames[i][0] == '#' ) { wchar_t *pName = g_pVGuiLocalize->Find( m_PlayerNames[i] ); if ( pName == NULL ) { g_pVGuiLocalize->ConvertANSIToUnicode( m_PlayerNames[i], szName, sizeof( szPlayerNames ) ); } else { Q_wcsncpy( szName, pName, sizeof( szName ) ); } nNumNames++; } else { g_pVGuiLocalize->ConvertANSIToUnicode( m_PlayerNames[i], szName, sizeof( szPlayerNames ) ); nNumNames++; } wcsncat( szPlayerNames, szName, sizeof( szPlayerNames ) ); } if ( nNumNames != 0 ) { wcsncat( szPlayerNames, L".", sizeof( szPlayerNames ) ); } SetControlString( "GameModeLabel", m_szGameMode ); SetControlVisible( "PlayerNames", ( nNumNames > 1 ) ); SetControlVisible( "StarringLabel", ( nNumNames > 1 ) ); SetControlVisible( "GameModeLabel", false ); SetControlString( "playernames", szPlayerNames ); SetControlEnabled( "LoadingTipPanel", false ); }
void DrawFogOfWarBlendedPass( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, FogOfWarBlendedPassVars_t &info, VertexCompressionType_t vertexCompression ) { bool bVertexLitGeneric = false; bool bHasFlashlight = false; SHADOW_STATE { bool hasBaseAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ); bool bHasSelfIllum = (!bHasFlashlight || IsX360() ) && IS_FLAG_SET( MATERIAL_VAR_SELFILLUM ); bool bIsAlphaTested = IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ) != 0; // Reset shadow state manually since we're drawing from two materials pShader->SetInitialShadowState(); // Set stream format (note that this shader supports compression) unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL | VERTEX_FORMAT_COMPRESSED; int nTexCoordCount = 1; int userDataSize = 0; pShaderShadow->VertexShaderVertexFormat( flags, nTexCoordCount, NULL, userDataSize ); // Vertex Shader DECLARE_STATIC_VERTEX_SHADER( fogofwar_blended_pass_vs20 ); SET_STATIC_VERTEX_SHADER_COMBO( FOW, true ); SET_STATIC_VERTEX_SHADER( fogofwar_blended_pass_vs20 ); // Pixel Shader DECLARE_STATIC_PIXEL_SHADER( fogofwar_blended_pass_ps20b ); SET_STATIC_PIXEL_SHADER_COMBO( BASEALPHAENVMAPMASK, hasBaseAlphaEnvmapMask ); SET_STATIC_PIXEL_SHADER_COMBO( SELFILLUM, bHasSelfIllum ); SET_STATIC_PIXEL_SHADER_COMBO( FOW, true ); SET_STATIC_PIXEL_SHADER( fogofwar_blended_pass_ps20b ); pShader->DefaultFog(); // Textures pShaderShadow->EnableTexture( SHADER_SAMPLER0, true ); pShaderShadow->EnableTexture( SHADER_SAMPLER1, true ); //pShaderShadow->EnableSRGBRead( SHADER_SAMPLER1, true ); // Blending pShader->EnableAlphaBlending( SHADER_BLEND_SRC_ALPHA, SHADER_BLEND_ONE_MINUS_SRC_ALPHA ); pShaderShadow->EnableAlphaTest( bIsAlphaTested ); pShaderShadow->AlphaFunc( SHADER_ALPHAFUNC_GREATER, 0.0f ); } DYNAMIC_STATE { // Decide if this pass should be drawn static ConVarRef sv_fogofwar("sv_fogofwar"); //static ConVarRef sv_fogofwar_tilesize("sv_fogofwar_tilesize"); if( !sv_fogofwar.GetBool() ) { pShader->Draw( false ); return; } // Reset render state manually since we're drawing from two materials pShaderAPI->SetDefaultState(); // Set Vertex Shader Combos DECLARE_DYNAMIC_VERTEX_SHADER( fogofwar_blended_pass_vs20 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, pShaderAPI->GetSceneFogMode() == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, pShaderAPI->GetCurrentNumBones() > 0 ); SET_DYNAMIC_VERTEX_SHADER( fogofwar_blended_pass_vs20 ); // Set Vertex Shader Constants //pShader->SetAmbientCubeDynamicStateVertexShader(); // Set Pixel Shader Combos DECLARE_DYNAMIC_PIXEL_SHADER( fogofwar_blended_pass_ps20b ); SET_DYNAMIC_PIXEL_SHADER( fogofwar_blended_pass_ps20b ); // Bind textures pShader->BindTexture( SHADER_SAMPLER0, info.m_nBaseTexture ); pShader->BindTexture( SHADER_SAMPLER1, info.m_nFogOfWarTexture ); // Set Pixel Shader Constants //pShader->SetModulationPixelShaderDynamicState_LinearColorSpace( 1 ); float eyePos[4]; pShaderAPI->GetWorldSpaceCameraPosition( eyePos ); pShaderAPI->SetPixelShaderConstant( 0, eyePos, 1 ); bool bWriteDepthToAlpha = pShaderAPI->ShouldWriteDepthToDestAlpha(); bool bWriteWaterFogToAlpha = false; bool bHasVertexAlpha = bVertexLitGeneric ? false : IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA ); float fPixelFogType = pShaderAPI->GetPixelFogCombo() == 1 ? 1 : 0; float fWriteDepthToAlpha = bWriteDepthToAlpha && IsPC() ? 1 : 0; float fWriteWaterFogToDestAlpha = bWriteWaterFogToAlpha ? 1 : 0; float fVertexAlpha = bHasVertexAlpha ? 1 : 0; // Controls for lerp-style paths through shader code (bump and non-bump have use different register) float vShaderControls[4] = { fPixelFogType, fWriteDepthToAlpha, fWriteWaterFogToDestAlpha, fVertexAlpha }; pShaderAPI->SetPixelShaderConstant( 1, vShaderControls, 1 ); pShaderAPI->SetPixelShaderFogParams(2); float vFoWSize[ 4 ]; Vector vMins = pShaderAPI->GetVectorRenderingParameter( VECTOR_RENDERPARM_GLOBAL_FOW_MINS ); Vector vMaxs = pShaderAPI->GetVectorRenderingParameter( VECTOR_RENDERPARM_GLOBAL_FOW_MAXS ); vFoWSize[ 0 ] = vMins.x; vFoWSize[ 1 ] = vMins.y; vFoWSize[ 2 ] = vMaxs.x - vMins.x; vFoWSize[ 3 ] = vMaxs.y - vMins.y; pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, vFoWSize ); /* // Fog of war color static float c[4]; c[0] = mat_fogofwar_r.GetFloat(); c[1] = mat_fogofwar_g.GetFloat(); c[2] = mat_fogofwar_b.GetFloat(); c[3] = mat_fogofwar_a.GetFloat(); pShaderAPI->SetPixelShaderConstant( 3, (const float *)(&c), 1 ); */ // Tilesize //static float ts[4]; //ts[0] = sv_fogofwar_tilesize.GetInt(); //pShaderAPI->SetPixelShaderConstant( 4, (const float *)(&ts), 1 ); } pShader->Draw(); }
//----------------------------------------------------------------------------- // Purpose: Advanced joystick setup //----------------------------------------------------------------------------- void CInput::Joystick_Advanced(void) { // called whenever an update is needed int i; DWORD dwTemp; if ( IsX360() ) { // Xbox always uses a joystick in_joystick.SetValue( 1 ); } // Initialize all the maps for ( i = 0; i < MAX_JOYSTICK_AXES; i++ ) { m_rgAxes[i].AxisMap = GAME_AXIS_NONE; m_rgAxes[i].ControlMap = JOY_ABSOLUTE_AXIS; } if ( !joy_advanced.GetBool() ) { // default joystick initialization // 2 axes only with joystick control m_rgAxes[JOY_AXIS_X].AxisMap = GAME_AXIS_YAW; m_rgAxes[JOY_AXIS_Y].AxisMap = GAME_AXIS_FORWARD; } else { if ( Q_stricmp( joy_name.GetString(), "joystick") != 0 ) { // notify user of advanced controller Msg( "Using joystick '%s' configuration\n", joy_name.GetString() ); } // advanced initialization here // data supplied by user via joy_axisn cvars dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisu.GetInt() : (DWORD)joy_advaxisx.GetInt(); m_rgAxes[JOY_AXIS_X].AxisMap = dwTemp & 0x0000000f; m_rgAxes[JOY_AXIS_X].ControlMap = dwTemp & JOY_RELATIVE_AXIS; DescribeJoystickAxis( "JOY_AXIS_X", &m_rgAxes[JOY_AXIS_X] ); dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisr.GetInt() : (DWORD)joy_advaxisy.GetInt(); m_rgAxes[JOY_AXIS_Y].AxisMap = dwTemp & 0x0000000f; m_rgAxes[JOY_AXIS_Y].ControlMap = dwTemp & JOY_RELATIVE_AXIS; DescribeJoystickAxis( "JOY_AXIS_Y", &m_rgAxes[JOY_AXIS_Y] ); dwTemp = (DWORD)joy_advaxisz.GetInt(); m_rgAxes[JOY_AXIS_Z].AxisMap = dwTemp & 0x0000000f; m_rgAxes[JOY_AXIS_Z].ControlMap = dwTemp & JOY_RELATIVE_AXIS; DescribeJoystickAxis( "JOY_AXIS_Z", &m_rgAxes[JOY_AXIS_Z] ); dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisy.GetInt() : (DWORD)joy_advaxisr.GetInt(); m_rgAxes[JOY_AXIS_R].AxisMap = dwTemp & 0x0000000f; m_rgAxes[JOY_AXIS_R].ControlMap = dwTemp & JOY_RELATIVE_AXIS; DescribeJoystickAxis( "JOY_AXIS_R", &m_rgAxes[JOY_AXIS_R] ); dwTemp = ( joy_movement_stick.GetBool() ) ? (DWORD)joy_advaxisx.GetInt() : (DWORD)joy_advaxisu.GetInt(); m_rgAxes[JOY_AXIS_U].AxisMap = dwTemp & 0x0000000f; m_rgAxes[JOY_AXIS_U].ControlMap = dwTemp & JOY_RELATIVE_AXIS; DescribeJoystickAxis( "JOY_AXIS_U", &m_rgAxes[JOY_AXIS_U] ); dwTemp = (DWORD)joy_advaxisv.GetInt(); m_rgAxes[JOY_AXIS_V].AxisMap = dwTemp & 0x0000000f; m_rgAxes[JOY_AXIS_V].ControlMap = dwTemp & JOY_RELATIVE_AXIS; DescribeJoystickAxis( "JOY_AXIS_V", &m_rgAxes[JOY_AXIS_V] ); Msg( "Advanced Joystick settings initialized\n" ); } // If we have an xcontroller, load the cfg file if it hasn't been loaded. static ConVarRef var( "joy_xcontroller_found" ); if ( var.IsValid() && var.GetBool() && in_joystick.GetBool() ) { if ( joy_xcontroller_cfg_loaded.GetInt() < 2 ) { engine->ClientCmd_Unrestricted( "exec 360controller.cfg" ); if ( IsLinux () ) { engine->ClientCmd_Unrestricted( "exec 360controller-linux.cfg" ); } joy_xcontroller_cfg_loaded.SetValue( 2 ); } } else if ( joy_xcontroller_cfg_loaded.GetInt() > 0 ) { engine->ClientCmd_Unrestricted( "exec undo360controller.cfg" ); joy_xcontroller_cfg_loaded.SetValue( 0 ); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *pSetup - //----------------------------------------------------------------------------- void ClientModeSDKNormal::OverrideView( CViewSetup *pSetup ) { QAngle camAngles; // Let the player override the view. C_SDKPlayer *pPlayer = (C_SDKPlayer*)C_BasePlayer::GetLocalPlayer(); if(!pPlayer) return; pPlayer->OverrideView( pSetup ); if( ::input->CAM_IsThirdPerson() ) { Vector cam_ofs; ::input->CAM_GetCameraOffset( cam_ofs ); camAngles[ PITCH ] = cam_ofs[ PITCH ]; camAngles[ YAW ] = cam_ofs[ YAW ]; camAngles[ ROLL ] = 0; Vector camForward, camRight, camUp; AngleVectors( camAngles, &camForward, &camRight, &camUp ); VectorMA( pSetup->origin, -cam_ofs[ ROLL ], camForward, pSetup->origin ); static ConVarRef c_thirdpersonshoulder( "c_thirdpersonshoulder" ); if ( c_thirdpersonshoulder.GetBool() ) { static ConVarRef c_thirdpersonshoulderoffset( "c_thirdpersonshoulderoffset" ); static ConVarRef c_thirdpersonshoulderheight( "c_thirdpersonshoulderheight" ); static ConVarRef c_thirdpersonshoulderaimdist( "c_thirdpersonshoulderaimdist" ); // add the shoulder offset to the origin in the cameras right vector VectorMA( pSetup->origin, c_thirdpersonshoulderoffset.GetFloat(), camRight, pSetup->origin ); // add the shoulder height to the origin in the cameras up vector VectorMA( pSetup->origin, c_thirdpersonshoulderheight.GetFloat(), camUp, pSetup->origin ); // adjust the yaw to the aim-point camAngles[ YAW ] += RAD2DEG( atan(c_thirdpersonshoulderoffset.GetFloat() / (c_thirdpersonshoulderaimdist.GetFloat() + cam_ofs[ ROLL ])) ); // adjust the pitch to the aim-point camAngles[ PITCH ] += RAD2DEG( atan(c_thirdpersonshoulderheight.GetFloat() / (c_thirdpersonshoulderaimdist.GetFloat() + cam_ofs[ ROLL ])) ); } // Override angles from third person camera VectorCopy( camAngles, pSetup->angles ); } else if (::input->CAM_IsOrthographic()) { pSetup->m_bOrtho = true; float w, h; ::input->CAM_OrthographicSize( w, h ); w *= 0.5f; h *= 0.5f; pSetup->m_OrthoLeft = -w; pSetup->m_OrthoTop = -h; pSetup->m_OrthoRight = w; pSetup->m_OrthoBottom = h; } }