void CEditorRoot::OnThink(void)
{
	BaseClass::OnThink();

	if ( IsBuildModeActive() )
	{
		Panel *pBuild = FindChildByName( "BuildModeDialog" );
		if ( pBuild && !pBuild->IsCursorOver() && input()->IsKeyDown( KEY_LCONTROL ) )
			pBuild->MoveToFront();
	}

	input()->GetCursorPosition( Mx, My );
	ScreenToLocal(Mx,My);

	Vector2D mCoords = GetSafeFlowgraph()->GetMousePosInNodeSpace();
	m_pLabel_Coords->SetText( VarArgs( "position: %10.1f / %10.1f", mCoords.x, mCoords.y ) );

	static CFastTimer _timer;
	_timer.End();
	double _frametime = _timer.GetDuration().GetSeconds();
	_timer.Start();
	m_pLabel_FrameTime->SetText( VarArgs( "fps: %4.1f, ms: %8.7f", 1.0f/max( 0.00001f, _frametime ), _frametime ) );

	if ( m_bPainting )
		input()->SetCursorOveride( dc_hand );

	// FML
	SortButtons();
	//if ( m_bNeedsButtonPush )
	//	SortButtons();

#ifdef SHADER_EDITOR_DLL_SWARM
	VPANEL modal = input()->GetAppModalSurface();
	static bool bFailed = false;

	if ( !bFailed && modal > 0 && modal != GetVPanel() )
	{
		if ( !m_bHalfView && IsVisible() && !ipanel()->HasParent( modal, GetVPanel() ) )
		{
			const char *pszModalName = ipanel()->GetName( modal );
			const char *names[] = {
				"SteamCloudConfirmation",
				"AddonAssociation",
			};

			const int numnames = ARRAYSIZE( names );
			for ( int i = 0; i < numnames; i++ )
			{
				if ( !Q_stricmp( names[i], pszModalName ) )
				{
					ToggleVisible();
					return;
				}
			}

			bFailed = true;
		}
	}
#endif
}
Exemplo n.º 2
0
void CSheet_Array::OnResetData()
{
	int num_x = pData->GetInt( "i_array_size_x", 1 );
	int num_y = pData->GetInt( "i_array_size_y", 1 );
	m_pTEntry_Size_X->SetText( VarArgs( "%i", num_x ) );
	m_pTEntry_Size_Y->SetText( VarArgs( "%i", num_y ) );
	m_pTEntry_Gauss_Bias->SetText( "0.0" );
	int iEnum = ::GetVarFlagsVarValue( pData->GetInt( "i_array_datatype" ) );
	m_pCBox_Datatype->ActivateItem( iEnum );

	UpdateArrayBlocks( num_x, num_y );

	::TokenChannels_t tokens;
	for ( int x = 0; x < num_x; x++ )
	{
		for ( int y = 0; y < num_y; y++ )
		{
			int element = num_y * x + y;

			char tmp[MAX_PATH];
			Q_snprintf( tmp, sizeof( tmp ), "%s", pData->GetString( VarArgs( "pfl_arraydata_%03i", element ) ) );

			tokens.bAllowChars = false;
			tokens.SetDefaultChannels();
			tokens.Tokenize( tmp );
			tokens.iActiveChannels = iEnum + 1;
			tokens.PrintTargetString( tmp, sizeof( tmp ) );

			m_hArray_Y_Major[ y ]->Element( x )->SetText( tmp );
		}
	}
}
Exemplo n.º 3
0
void CNodeCustom::FillJackDataFromKV( KeyValues *pKV, CUtlVector< __funcParamSetup* > &m_hIn, CUtlVector< __funcParamSetup* > &m_hOut )
{
	Assert( m_hIn.Count() == 0 );
	Assert( m_hOut.Count() == 0 );

	const char *nullString = "";
	int itr = 0;

	for (;;)
	{
		const char *read_name = pKV->GetString( VarArgs( "varName_In_%i", itr ), nullString );
		const int read_type = pKV->GetInt( VarArgs( "varType_In_%i", itr ), 0 );

		if ( read_type == 0 )
			break;

		m_hIn.AddToTail( AllocOutputSetup( false, read_name, read_type ) );
		itr++;
	}

	itr = 0;

	for (;;)
	{
		const char *read_name = pKV->GetString( VarArgs( "varName_Out_%i", itr ), nullString );
		const int read_type = pKV->GetInt( VarArgs( "varType_Out_%i", itr ), 0 );

		if ( read_type == 0 )
			break;

		m_hOut.AddToTail( AllocOutputSetup( true, read_name, read_type ) );
		itr++;
	}
}
void CDialog_RendertargetList::FillList()
{
	ScrollBar *pScroll = m_pList_RT->GetScrollbar();
	int scrollValue = pScroll ? pScroll->GetValue() : 0;

	m_pList_RT->DeleteAllItems();

	GetRTManager()->SortRTsByName();
	for ( int i = 0; i < GetRTManager()->GetNumRTs(); i++ )
	{
		RTDef *rt = GetRTManager()->GetRT( i );

		if ( rt->IsFlaggedForDeletion() )
			continue;

		Label *pL = new Label( m_pList_RT, "", rt->GetName() );
		Button *pBDel = new Button( m_pList_RT, "", "Delete", this, VarArgs("del_rt_%i",i) );
		Button *pBEdit = new Button( m_pList_RT, "", "Edit", this, VarArgs("edit_rt_%i",i) );

		pBDel->SetContentAlignment( Label::a_center );
		pBEdit->SetContentAlignment( Label::a_center );

		m_pList_RT->AddItem( pL, pBDel );
		m_pList_RT->AddItem( NULL, pBEdit );
	}

	if ( pScroll )
		pScroll->SetValue( scrollValue );
}
Exemplo n.º 5
0
StatsReport::StatsReport( vgui::Panel *parent, const char *name ) : vgui::EditablePanel( parent, name )
{
	m_pObjectiveMap = new ObjectiveMap( this, "ObjectiveMap" );
	
	for ( int i = 0; i < ASW_STATS_REPORT_CATEGORIES; i++ )
	{
		const char *pButtonName = VarArgs( "CategoryButton%d", i );
		m_pCategoryButtons[ i ] = new vgui::Button( this, pButtonName, "", this, pButtonName );
	}

	for ( int i = 0; i < ASW_STATS_REPORT_MAX_PLAYERS; i++ )
	{
		m_pPlayerNames[ i ] = new vgui::Label( this, VarArgs( "PlayerName%d", i ), "" );
		m_pReadyCheckImages[ i ] = new vgui::ImagePanel( this, VarArgs( "ReadyCheck%d", i ) );
		m_pReadyCheckImages[ i ]->SetShouldScaleImage( true );
		m_pAvatarImages[ i ] = new CAvatarImagePanel( this, VarArgs( "AvatarImage%d", i ) );
	}

	m_pPlayerNamesPosition = new vgui::Panel( this, "PlayerNamesPosition" );

	m_pStatGraphPlayer = new StatGraphPlayer( this, "StatGraphPlayer" );

	m_pDebrief = new DebriefTextPage( this, "Debrief" );

	m_rgbaStatsReportPlayerColors[ 0 ] = Color( 225, 60, 60, 255 );
	m_rgbaStatsReportPlayerColors[ 1 ] = Color( 200, 200, 60, 255 );
	m_rgbaStatsReportPlayerColors[ 2 ] = Color( 60, 225, 60, 255 );
	m_rgbaStatsReportPlayerColors[ 3 ] = Color( 30, 90, 225, 255 );
}
Exemplo n.º 6
0
void CNodeCustom::WriteJackDataFromKV( KeyValues *pKV, CUtlVector< __funcParamSetup* > &m_hIn, CUtlVector< __funcParamSetup* > &m_hOut,
										int maxIn, int maxOut )
{
	for ( int i = 0; i < maxIn; i++ )
	{
		const char *pName = VarArgs( "varName_In_%i", i );
		if ( i < m_hIn.Count() )
			pKV->SetString( pName, m_hIn[ i ]->pszName );
		else
			pKV->SetString( pName, "" );

		pName = VarArgs( "varType_In_%i", i );
		if ( i < m_hIn.Count() )
			pKV->SetInt( pName, m_hIn[ i ]->iFlag );
		else
			pKV->SetInt( pName, HLSLVAR_FLOAT1 );
	}

	for ( int i = 0; i < maxOut; i++ )
	{
		const char *pName = VarArgs( "varName_Out_%i", i );
		if ( i < m_hOut.Count() )
			pKV->SetString( pName, m_hOut[ i ]->pszName );
		else
			pKV->SetString( pName, "" );

		pName = VarArgs( "varType_Out_%i", i );
		if ( i < m_hOut.Count() )
			pKV->SetInt( pName, m_hOut[ i ]->iFlag );
		else
			pKV->SetInt( pName, HLSLVAR_FLOAT1 );
	}
}
//-----------------------------------------------------------------------------
// Purpose: called every frame to get ammo info from the weapon
//-----------------------------------------------------------------------------
void CDoDHudAmmo::OnThink()
{
    C_BaseCombatWeapon *wpn = GetActiveWeapon();
    C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();

    hudlcd->SetGlobalStat( "(weapon_print_name)", wpn ? wpn->GetPrintName() : " " );
    hudlcd->SetGlobalStat( "(weapon_name)", wpn ? wpn->GetName() : " " );

    if ( !wpn || !player || !wpn->UsesPrimaryAmmo() )
    {
        hudlcd->SetGlobalStat( "(ammo_primary)", "n/a" );
        hudlcd->SetGlobalStat( "(ammo_secondary)", "n/a" );

        SetPaintEnabled( false );
        SetPaintBackgroundEnabled( false );
        return;
    }
    else
    {
        SetPaintEnabled( true );
        SetPaintBackgroundEnabled( true );
    }

    // get the ammo in our clip
    int ammo1 = wpn->Clip1();
    int ammo2;
    if ( ammo1 < 0 )
    {
        // we don't use clip ammo, just use the total ammo count
        ammo1 = player->GetAmmoCount( wpn->GetPrimaryAmmoType() );
        ammo2 = 0;
    }
    else
    {
        // we use clip ammo, so the second ammo is the total ammo
        ammo2 = player->GetAmmoCount( wpn->GetPrimaryAmmoType() );
    }

    hudlcd->SetGlobalStat( "(ammo_primary)", VarArgs( "%d", ammo1 ) );
    hudlcd->SetGlobalStat( "(ammo_secondary)", VarArgs( "%d", ammo2 ) );

    if ( wpn == m_hCurrentActiveWeapon )
    {
        // same weapon, just update counts
        SetAmmo( ammo1, true );
        SetAmmo2( ammo2, true );
    }
    else
    {
        // diferent weapon, change without triggering
        SetAmmo( ammo1, false );
        SetAmmo2( ammo2, false );

        // update whether or not we show the total ammo display
        m_bUsesClips = wpn->UsesClipsForAmmo1();
        m_hCurrentActiveWeapon = wpn;
    }
}
void CSheet_VSInput::OnSliderMoved( int position )
{
	int numTex = m_pSlider_tex->GetValue();
	int numCol = m_pSlider_col->GetValue();

	m_pLabel_Info_Num_TexCoords->SetText( VarArgs( "%1i", numTex ) );
	m_pLabel_Info_Num_Colors->SetText( VarArgs( "%1i", numCol ) );

	for ( int d = 0; d < 3; d++ )
		m_pCBox_DType_TexCoords[d]->SetEnabled( numTex - 1 >= d );
	for ( int d = 0; d < 2; d++ )
		m_pCBox_DType_Color[d]->SetEnabled( numCol - 1 >= d );
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CControlPointIcon::UpdateImage( void )
{
	int iOwner = ObjectiveResource()->GetOwningTeam( m_iCPIndex );

	if ( m_pBaseImage )
	{
		int iOwnerIcon = ObjectiveResource()->GetCPCurrentOwnerIcon( m_iCPIndex, iOwner );
		const char *szMatName = GetMaterialNameFromIndex( iOwnerIcon );

		if ( IsPointLocked() )
		{
			m_pBaseImage->SetImage( VarArgs("..\\%s_locked", szMatName ) );
		}
		else
		{
			m_pBaseImage->SetImage( VarArgs("..\\%s", szMatName ) );
		}
	}

	if ( m_pOverlayImage )
	{
		int iOverlayIcon = ObjectiveResource()->GetOverlayForTeam( m_iCPIndex, iOwner );
		if ( iOverlayIcon )
		{
			const char *szMatName = GetMaterialNameFromIndex( iOverlayIcon );
			m_pOverlayImage->SetImage( VarArgs("..\\%s", szMatName ) );
			m_pOverlayImage->SetVisible( true );
		}
		else
		{
			m_pOverlayImage->SetVisible( false );
		}
	}

	// Whenever a successful cap occurs, flash the cap point
	if ( m_pCapPulseImage )
	{
		if ( m_iPrevCappers != 0 && iOwner == m_iPrevCappers )
		{
			m_iPrevCappers = 0;

			if ( ShouldDraw() )
			{
				m_pCapPulseImage->SetVisible( true );
				m_pCapPulseImage->StartPulse( gpGlobals->curtime, GetWide() );
			}
			m_pBaseImage->StartPulsing( FINISHCAPANIM_SWOOP_LENGTH, 0.5, false );
		}
		
	}
}
void CDialog_RendertargetSettings::SetDefaults()
{
	m_pText_RTName->SetText( "" );
	m_pText_SizeX->SetText( VarArgs( "%i", RT_DEFAULT_SIZE ) );
	m_pText_SizeY->SetText( VarArgs( "%i", RT_DEFAULT_SIZE ) );

	m_pCBox_ImgFormat->ActivateItem( 0 );
	m_pCBox_SizeMode->ActivateItem( 0 );
	m_pCBox_DepthMode->ActivateItem( 2 );

	for ( int i = 0; i < m_hFlag_Buttons.Count(); i++ )
	{
		m_hFlag_Buttons[i]->SetSelected( (TEXTUREFLAGS_RENDERTARGET & ( 1 << i )) != 0 );
	}
}
Exemplo n.º 11
0
void CSheet_Array::OnApplyChanges()
{
	int cur_x, cur_y;
	char ***entries = BuildStringSheet( cur_x, cur_y );
	int iEnum = clamp( m_pCBox_Datatype->GetActiveItem(), 0, 3 );

	pData->SetInt( "i_array_datatype", ::GetVarTypeFlag( iEnum ) );
	pData->SetInt( "i_array_size_x", cur_x );
	pData->SetInt( "i_array_size_y", cur_y );

	::TokenChannels_t tokens;

	for ( int x = 0; x < cur_x; x++ )
	{
		for ( int y = 0; y < cur_y; y++ )
		{
			int element = cur_y * x + y;
			//m_hArray_X_Major[ x ]->Element( y )->GetText( tmp, sizeof( tmp ) );
			char *str = entries[x][y];
			char tmp[MAX_PATH];

			tokens.bAllowChars = false;
			tokens.Tokenize( str );
			tokens.PrintTargetString( tmp, sizeof( tmp ) );
			pData->SetString( VarArgs( "pfl_arraydata_%03i", element ), tmp );
		}
	}

	DestroyStringSheet( entries, cur_x, cur_y );
}
void CEditorRoot::SaveLayout()
{
	KeyValues *pKV = new KeyValues( "config" );

	pKV->SetInt( "preview_visible", (pPreview && pPreview->IsVisible()) );
	if ( pPreview )
		pPreview->GetBounds( px, py, psx, psy );

	pKV->SetInt( "p_x", px );
	pKV->SetInt( "p_y", py );
	pKV->SetInt( "p_sx", psx );
	pKV->SetInt( "p_sy", psy );

	pKV->SetInt( "draw_datatypes", m_bDraw_Datatypes ? 1 : 0 );
	pKV->SetInt( "draw_shadows", m_bDraw_Shadows ? 1 : 0 );
	pKV->SetInt( "draw_all_limits", m_bDraw_AllLimits ? 1 : 0 );
	pKV->SetInt( "compile_preview", m_bAutoCompile ? 1 : 0 );
	pKV->SetInt( "enable_nodeview_tooltips", m_bDoTooltips ? 1 : 0 );
	pKV->SetInt( "compile_always_full", m_bAutoFullcompile ? 1 : 0 );
	pKV->SetInt( "compile_auto_publish_to_materials", m_bAutoShaderPublish ? 1 : 0 );
	pKV->SetInt( "precache_auto_reload", m_bAutoPrecacheUpdate ? 1 : 0 );
	pKV->SetInt( "warn_unsaved_changes", m_bWarnOnClose ? 1 : 0 );

	pKV->SetInt( "cedit_x", cedit_x );
	pKV->SetInt( "cedit_y", cedit_y );
	pKV->SetInt( "cedit_sx", cedit_sx );
	pKV->SetInt( "cedit_sy", cedit_sy );
	
	pKV->SaveToFile( filesystem, VarArgs( "%s/shadereditorui/editor_config.txt", engine->GetGameDirectory()), "MOD" );
	pKV->deleteThis();

	//DeallocPingPongRTs();
}
Exemplo n.º 13
0
void CNodePSOutput::Setup( SETUP_HLSL_PS_Output info )
{
	int numInputs = 0;
	numInputs += info.iNumRTs;
	if ( info.bDepth )
		numInputs += 1;

	CUtlVector< BridgeRestoreInfo* >m_hRestoreBridges;
	CreateBridgeRestoreData_In( CBaseNode::BY_RESTYPE, m_hRestoreBridges );

	GenerateJacks_Input( numInputs );

	int curInput = 0;

	for ( int i = 0; i < info.iNumRTs; i++ )
	{
		GetJack_In( curInput )->SetResourceType( RESOURCETYPE_COLOR_0 + i );
		LockJackInput_Flags( curInput, HLSLVAR_FLOAT4, VarArgs("Color %i",i) );
		curInput++;
	}
	if ( info.bDepth )
	{
		GetJack_In( curInput )->SetResourceType( RESOURCETYPE_DEPTH );
		LockJackInput_Flags( curInput, HLSLVAR_FLOAT1, "Depth" );
		curInput++;
	}

	curSetup = info;
	RestoreBridgesFromList_In( m_hRestoreBridges );
}
Exemplo n.º 14
0
	virtual void LevelInitPreEntity()
	{
		BaseClass::LevelInitPreEntity();

		if (engine->IsPlayingDemo())
			return;

		if (engine->IsRecordingDemo())
			return;

		if (asw_auto_record.GetBool())
		{
			if (asw_auto_record.GetInt() > 0)
			{
				DeleteOldRecordings(asw_auto_record.GetInt() - 1);
			}

			struct tm now;
			Plat_GetLocalTime(&now);
			// we assume a map will only be started once per second, and that if a map is started multiple times per second, the old recordings aren't useful.
			// our date format is RFC2550 compliant until January 1st 10000.
			engine->ClientCmd_Unrestricted(VarArgs("record \"aswauto-%04d%02d%02d%02d%02d%02d_%s\"", now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, MapName()));
			m_bIsRecording = true;
		}
	}
void CNB_Spend_Skill_Points::OnThink()
{
	BaseClass::OnThink();

	CASW_Marine_Profile *pProfile = Briefing()->GetMarineProfileByProfileIndex( m_nProfileIndex );
	if ( pProfile )
	{
		char imagename[255];
		Q_snprintf( imagename, sizeof(imagename), "briefing/face_%s", pProfile->m_PortraitName );
		m_pSelectedMarine->SetImage( imagename );

		m_pMarineNameLabel->SetText( pProfile->GetShortName() );
		m_pBioLabel->SetText( pProfile->m_Bio );
		int nMouseOverSkill = -1;
		for ( int i = 0; i < NUM_SKILL_PANELS; i++ )
		{
			m_pSkillPanel[ i ]->SetSkillDetails( m_nProfileIndex, i, Briefing()->GetProfileSkillPoints( m_nProfileIndex, i ) );
			m_pSkillPanel[ i ]->m_bSpendPointsMode = true;
			if ( m_pSkillPanel[ i ]->IsCursorOver() )
			{
				nMouseOverSkill = i;
			}
		}	
		if ( nMouseOverSkill != -1 && MarineSkills() )
		{
			ASW_Skill nSkillIndex = pProfile->GetSkillMapping( nMouseOverSkill );		// translate from skill slot to skill index

			m_pSkillTitle->SetText( MarineSkills()->GetSkillName( nSkillIndex ) );
			m_pSkillDescription->SetText( MarineSkills()->GetSkillDescription( nSkillIndex ) );
		}
		m_pSpareSkillPointsLabel->SetText( VarArgs( "%d", Briefing()->GetProfileSkillPoints( m_nProfileIndex, ASW_SKILL_SLOT_SPARE ) ) );
	}
}
Exemplo n.º 16
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bnewentity - 
//-----------------------------------------------------------------------------
void C_EntityFlame::OnDataChanged( DataUpdateType_t updateType )
{
	if ( updateType == DATA_UPDATE_CREATED )
	{
		C_BaseEntity *pEnt = m_hEntAttached;
		if ( !pEnt )
			return;
		
		if ( m_bUseHitboxes && pEnt->GetBaseAnimating() != NULL )
		{
			AttachToHitBoxes();
		}
		else
		{
			m_vecLastPosition = GetRenderOrigin();

			m_ParticleSpawn.Init( 60 ); //Events per second

			m_pEmitter = CEmberEffect::Create("C_EntityFlame::Create");
			
			Assert( m_pEmitter.IsValid() );
			if ( m_pEmitter.IsValid() )
			{
				for ( int i = 1; i < NUM_FLAMELETS+1; i++ )
				{
					m_MaterialHandle[i-1] = m_pEmitter->GetPMaterial( VarArgs( "sprites/flamelet%d", i ) );
				}

				m_pEmitter->SetSortOrigin( GetAbsOrigin() );
			}
		}
	}

	BaseClass::OnDataChanged( updateType );
}
Exemplo n.º 17
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : bnewentity - 
//-----------------------------------------------------------------------------
void C_EntityFlame::OnDataChanged( DataUpdateType_t updateType )
{
	if ( updateType == DATA_UPDATE_CREATED )
	{
		SetupEntityRenderHandle( RENDER_GROUP_TRANSLUCENT_ENTITY );

		C_BaseEntity *pEnt = m_hEntAttached;
		
		// FIXME: this should be IsBaseAnimating
		if (pEnt->IsBaseCombatCharacter())
		{
			AttachToHitBoxes();
		}
		else
		{
			m_ParticleSpawn.Init( 60 ); //Events per second

			m_pEmitter = CEmberEffect::Create("C_EntityFlame::Create");
			
			Assert( m_pEmitter.IsValid() );
			if ( m_pEmitter.IsValid() )
			{
				for ( int i = 1; i < NUM_FLAMELETS+1; i++ )
				{
					m_MaterialHandle[i-1] = m_pEmitter->GetPMaterial( VarArgs( "sprites/flamelet%d", i ) );
				}

				m_pEmitter->SetSortOrigin( GetAbsOrigin() );
			}
		}
	}
}
Exemplo n.º 18
0
//-----------------------------------------------------------------------------
// Purpose
//-----------------------------------------------------------------------------
void C_BaseViewModel::FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options )
{
	// We override sound requests so that we can play them locally on the owning player
	if ( ( event == AE_CL_PLAYSOUND ) || ( event == CL_EVENT_SOUND ) )
	{
		// Only do this if we're owned by someone
		if ( GetOwner() != NULL )
		{
			CLocalPlayerFilter filter;
			EmitSound( filter, GetOwner()->GetSoundSourceIndex(), options, &GetAbsOrigin() );
			return;
		}
	}

	// Otherwise pass the event to our associated weapon
	C_BaseCombatWeapon *pWeapon = GetActiveWeapon();
	if ( pWeapon )
	{
		// NVNT notify the haptics system of our viewmodel's event
		if ( haptics )
			haptics->ProcessHapticEvent(4,"Weapons",pWeapon->GetName(),"AnimationEvents",VarArgs("%i",event));

		bool bResult = pWeapon->OnFireEvent( this, origin, angles, event, options );
		if ( !bResult )
		{
			BaseClass::FireEvent( origin, angles, event, options );
		}
	}
}
//=============================================================================
void ControllerOptionsButtons::OnCommand(const char *command)
{
	for ( int i=0;i<NUM_CONTROLLER_BUTTONS_SETTINGS;i++ )
	{
		if( !Q_strcmp( command, pszButtonSettingsButtonName[i] ) )
		{
			CGameUIConVarRef joy_cfg_preset( "joy_cfg_preset" );
			if ( joy_cfg_preset.IsValid() )
			{
				joy_cfg_preset.SetValue( i );
			}

			int iOldSlot = engine->GetActiveSplitScreenPlayerSlot();
			engine->SetActiveSplitScreenPlayerSlot( m_iActiveUserSlot );

			const char *pszCfg = pszButtonSettingConfigs[i];
			engine->ExecuteClientCmd( VarArgs( "exec %s", pszCfg ) );

			engine->SetActiveSplitScreenPlayerSlot( iOldSlot );

//			RecalculateBindingLabels();
			m_nRecalculateLabelsTicks = 1; // used to delay polling the values until we've flushed the command buffer 
			return;
		}
	}

	BaseClass::OnCommand( command );
}
//-----------------------------------------------------------------------------
// Purpose: Create the icons we need to display the state of this map's control points
//-----------------------------------------------------------------------------
void CHudControlPointIcons::InitIcons( void )
{
	ShutdownIcons();

	CTFHudObjectiveStatus *pStatus = GET_HUDELEMENT( CTFHudObjectiveStatus );
	if ( pStatus )
	{
		CControlPointProgressBar *pProgressBar = pStatus->GetControlPointProgressBar();

		if ( pProgressBar )
		{
			m_iCurrentCP = -1;
			pProgressBar->SetupForPoint( NULL );
		}
	}

	// Create an icon for each visible control point in this miniround
	int iPoints = ObjectiveResource()->GetNumControlPoints();
	for ( int i = 0; i < iPoints; i++ )
	{
		if ( ObjectiveResource()->IsInMiniRound(i) && ObjectiveResource()->IsCPVisible(i) )
		{
			CControlPointIcon *pIcon = new CControlPointIcon( this, VarArgs( "ControlPointIcon%d", i ), i );
			m_Icons.AddToTail( vgui::SETUP_PANEL(pIcon) );
		}
	}

	InvalidateLayout();
}
Exemplo n.º 21
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
IMaterial *CreateTempMaterialForPlayerLogo( int iPlayerIndex, player_info_t *info, char *texname, int nchars )
{
	// Doesn't have a logo?
	if ( !info->customFiles[0] )	
		return NULL;

	IMaterial *logo = materials->FindMaterial( VarArgs("decals/playerlogo%2.2d", iPlayerIndex), TEXTURE_GROUP_DECAL );
	if ( IsErrorMaterial( logo ) )
		return NULL;

	char logohex[ 16 ];
	Q_binarytohex( (byte *)&info->customFiles[0], sizeof( info->customFiles[0] ), logohex, sizeof( logohex ) );

	// See if logo has been downloaded.
	Q_snprintf( texname, nchars, "temp/%s", logohex );
	char fulltexname[ 512 ];
	Q_snprintf( fulltexname, sizeof( fulltexname ), "materials/temp/%s.vtf", logohex );

	if ( !filesystem->FileExists( fulltexname ) )
	{
		char custname[ 512 ];
		Q_snprintf( custname, sizeof( custname ), "download/user_custom/%c%c/%s.dat", logohex[0], logohex[1], logohex );
		// it may have been downloaded but not copied under materials folder
		if ( !filesystem->FileExists( custname ) )
			return NULL; // not downloaded yet

		// copy from download folder to materials/temp folder
		// this is done since material system can access only materials/*.vtf files

		if ( !engine->CopyLocalFile( custname, fulltexname) )
			return NULL;
	}

	return logo;
}
Exemplo n.º 22
0
//-----------------------------------------------------------------------------
// Purpose: Starts the effect
// Input  : *pParticleMgr - 
//			*pArgs - 
//-----------------------------------------------------------------------------
void C_SmokeStack::Start(CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs)
{
	pParticleMgr->AddEffect( &m_ParticleEffect, this );
	
	// Figure out the material name.
	char str[512] = "unset_material";
	const model_t *pModel = modelinfo->GetModel( m_iMaterialModel );
	if ( pModel )
	{
		Q_strncpy( str, modelinfo->GetModelName( pModel ), sizeof( str ) );

		// Get rid of the extension because the material system doesn't want it.
		char *pExt = Q_stristr( str, ".vmt" );
		if ( pExt )
			pExt[0] = 0;
	}

	m_MaterialHandle[0] = m_ParticleEffect.FindOrAddMaterial( str );

	int iCount = 1;
	char szNames[512];

	int iLength = Q_strlen( str );
	str[iLength-1] = '\0';

	Q_snprintf( szNames, sizeof( szNames ), "%s%d.vmt", str, iCount );

	while ( filesystem->FileExists( VarArgs( "materials/%s", szNames ) ) && iCount < SMOKESTACK_MAX_MATERIALS )
	{
		char *pExt = Q_stristr( szNames, ".vmt" );
		if ( pExt )
			pExt[0] = 0;

		m_MaterialHandle[iCount] = m_ParticleEffect.FindOrAddMaterial( szNames );
		iCount++;
	}

	m_iMaxFrames = iCount-1;

	m_ParticleSpawn.Init( mat_reduceparticles.GetBool() ? m_Rate / 4 : m_Rate ); // Obey mat_reduceparticles in episodic

	m_InvLifetime = m_Speed / m_JetLength;

	m_pParticleMgr = pParticleMgr;

	// Figure out how we need to draw.
	IMaterial *pMaterial = pParticleMgr->PMaterialToIMaterial( m_MaterialHandle[0] );
	if( pMaterial )
	{
		m_Renderer.Init( pParticleMgr, pMaterial );
	}
	
	QueueLightParametersInRenderer();

	// For the first N seconds, always simulate so it can build up the smokestack.
	// Afterwards, we set it to freeze when it's not being rendered.
	m_ParticleEffect.SetAlwaysSimulate( true );
	SetNextClientThink( gpGlobals->curtime + 5 );
}
void CSheet_VSInput::OnApplyChanges()
{
	pData->SetInt( "numTexcoords",m_pSlider_tex->GetValue() );
	pData->SetInt( "numColor",m_pSlider_col->GetValue() );

	pData->SetInt( "enable_flex", m_pCheck_flex->IsSelected() ? 1 : 0 );
	pData->SetInt( "enable_normal", m_pCheck_normal->IsSelected() ? 1 : 0 );
	pData->SetInt( "enable_normal_compression", m_pCheck_normal_compression->IsSelected() ? 1 : 0 );
	pData->SetInt( "enable_tangentspace", m_pCheck_tangent->IsSelected() ? 1 : 0 );
	pData->SetInt( "enable_blendweights", m_pCheck_blend->IsSelected() ? 1 : 0 );
	pData->SetInt( "enable_tangentspace_skinning", m_pCheck_tangent_skinable->IsSelected() ? 1 : 0 );

	for ( int d = 0; d < 3; d++ )
		pData->SetInt( VarArgs( "dTFlag_Texcoords_%i", d ), ::GetVarTypeFlag( m_pCBox_DType_TexCoords[d]->GetActiveItem() ) );
	for ( int d = 0; d < 2; d++ )
		pData->SetInt( VarArgs( "dTFlag_Color_%i", d ), ::GetVarTypeFlag( m_pCBox_DType_Color[d]->GetActiveItem() ) );
}
Exemplo n.º 24
0
void CASW_HUD_Health_Cross::OnThink()
{
	if ( !m_hPortrait.Get() )
		return;

	if ( !m_hPortrait->m_hMarineResource.Get() || !m_hPortrait->m_hMarineResource->GetMarineEntity() )
		return;

	int iHealth = MAX( 0, m_hPortrait->m_hMarineResource->GetMarineEntity()->GetHealth() );

	if ( iHealth != m_iHealth )
	{
		m_iHealth = iHealth;
		
		m_pHealthLabel->SetText( VarArgs( "%d", iHealth ) );
		m_pHealthLabelShadow->SetText( VarArgs( "%d", iHealth ) );
	}
}
void CSheet_VSInput::OnResetData()
{
	m_pSlider_tex->SetValue( pData->GetInt( "numTexcoords" ) );
	m_pSlider_col->SetValue( pData->GetInt( "numColor" ) );

	m_pCheck_flex->SetSelected( ( pData->GetInt( "enable_flex" ) != 0 ) );
	m_pCheck_normal->SetSelected( ( pData->GetInt( "enable_normal" ) != 0 ) );
	m_pCheck_normal_compression->SetSelected( ( pData->GetInt( "enable_normal_compression" ) != 0 ) );
	m_pCheck_tangent->SetSelected( ( pData->GetInt( "enable_tangentspace" ) != 0 ) );
	m_pCheck_blend->SetSelected( ( pData->GetInt( "enable_blendweights" ) != 0 ) );
	m_pCheck_tangent_skinable->SetSelected( ( pData->GetInt( "enable_tangentspace_skinning" ) != 0 ) );

	for ( int d = 0; d < 3; d++ )
		m_pCBox_DType_TexCoords[d]->ActivateItem( ::GetVarFlagsVarValue( pData->GetInt( VarArgs( "dTFlag_Texcoords_%i", d ) ) ) );

	for ( int d = 0; d < 2; d++ )
		m_pCBox_DType_Color[d]->ActivateItem( ::GetVarFlagsVarValue( pData->GetInt( VarArgs( "dTFlag_Color_%i", d ) ) ) );
}
Exemplo n.º 26
0
//Might be able to handle this better...
void HapticsHandleMsg_SPHapWeapEvent( int iActivity )
{
	C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer();
	C_BaseCombatWeapon* weap = NULL;
	if(pPlayer)
		weap = pPlayer->GetActiveWeapon();
	if(weap)
		haptics->ProcessHapticEvent(4,"Weapons",weap->GetName(),"Activities",VarArgs("%i",iActivity));
}
void CEditorRoot::OnAskPageClose( KeyValues *pKV )
{
	Panel *pPageTab = (Panel*)pKV->GetPtr( "PageTab" );
	CNodeView *pGraph = GetFlowGraph( pKV->GetInt( "TabIndex" ) );

	if ( pPageTab == NULL ||
		pGraph == NULL )
	{
		Assert( 0 );
		return;
	}

	ConfirmTabClose( pPageTab->GetVPanel() );

#if 0
	if ( !m_bWarnOnClose || !pGraph->IsSaveDirty() )
		ConfirmTabClose( pPageTab->GetVPanel() );
	else
	{
		const char *pszShadername = pGraph->GetShadername();

		char shortName[MAX_PATH*4];

		KeyValues *pKVResponse_Yes = new KeyValues( "ResponseGraphSave", "DoSave", 1 );
		KeyValues *pKVResponse_No = new KeyValues( "ResponseGraphSave", "DoSave", 0 );

		if ( pszShadername == NULL )
		{
			pKVResponse_No->deleteThis();
			pKVResponse_No = new KeyValues( "ResponseGraphSave", "DoSave", 2 );
		}
		else
		{
			Q_FileBase( pszShadername, shortName, sizeof( shortName ) );
		}

		pKVResponse_Yes->SetPtr( "PageTab", pPageTab );
		pKVResponse_No->SetPtr( "PageTab", pPageTab );
		pKVResponse_Yes->SetPtr( "Graph", pGraph );
		pKVResponse_No->SetPtr( "Graph", pGraph );

		vgui::PromptSimple *prompt = new vgui::PromptSimple( this, "Unsaved changes" );
		prompt->MoveToCenterOfScreen();

		if ( pszShadername != NULL )
			prompt->SetText( VarArgs( "The graph %s has unsaved changes. Save now?", shortName ) );
		else
			prompt->SetText( "This graph has not been saved yet, are you sure that you want to close it?" );

		prompt->AddButton( "Yes", pKVResponse_Yes );
		prompt->AddButton( "No", pKVResponse_No );
		prompt->MakeReadyForUse();
		prompt->InvalidateLayout( true, true );
	}
#endif
}
void CDialog_RendertargetSettings::InitFromRT( RTDef *rt )
{
	m_pRTTarget = rt;

	m_pText_RTName->SetText( rt->GetName() );
	m_pText_SizeX->SetText( VarArgs( "%i", rt->GetSizeX() ) );
	m_pText_SizeY->SetText( VarArgs( "%i", rt->GetSizeY() ) );

	m_pCBox_ImgFormat->ActivateItem( rt->GetImgFormat() );
	m_pCBox_SizeMode->ActivateItem( rt->GetSizeMode() );
	m_pCBox_DepthMode->ActivateItem( rt->GetDepthMode() );

	unsigned int flags = rt->GetFlags();
	Assert( m_hFlag_Buttons.Count() == iNumVTFFlags );

	for ( int i = 0; i < m_hFlag_Buttons.Count(); i++ )
	{
		m_hFlag_Buttons[i]->SetSelected( !!(flags & ( 1 << i )) );
	}
}
void CDialog_PPEPrecache::FillList()
{
	ScrollBar *pScroll = m_pList_Effects->GetScrollbar();
	int scrollValue = pScroll ? pScroll->GetValue() : 0;

	m_pList_Effects->DeleteAllItems();

	GetPPCache()->ClearInvalidEntries();

	HFont fontMarlett = scheme()->GetIScheme( GetScheme() )->GetFont( "Marlett", false );

	for ( int i = 0; i < GetPPCache()->GetNumPostProcessingEffects(); i++ )
	{
		EditorPostProcessingEffect *effect = GetPPCache()->GetPostProcessingEffect( i );

		Label *pL = new Label( m_pList_Effects, "", effect->pszName );
		Button *pDel = new Button( m_pList_Effects, "", "Delete", this, VarArgs("del_effect_%i",i) );
		CheckButton *pCheck = new CheckButton( m_pList_Effects, effect->pszName, "" );

		pCheck->AddActionSignalTarget( this );
		pCheck->SetSelected( effect->bStartEnabled );

		Button *pDown = new Button( m_pList_Effects, "", "u", this, VarArgs("movedown_effect_%i",i) );
		Button *pUp = new Button( m_pList_Effects, "", "t", this, VarArgs("moveup_effect_%i",i) );

		pDown->SetFont( fontMarlett );
		pUp->SetFont( fontMarlett );

		pDel->SetContentAlignment( Label::a_center );
		pDown->SetContentAlignment( Label::a_center );
		pUp->SetContentAlignment( Label::a_center );

		m_pList_Effects->AddItem( NULL, pCheck );
		m_pList_Effects->AddItem( NULL, pDown );
		m_pList_Effects->AddItem( NULL, pUp );
		m_pList_Effects->AddItem( pL, pDel );
	}

	if ( pScroll )
		pScroll->SetValue( scrollValue );
}
Exemplo n.º 30
0
void CNodeVSInput::RestoreFromKeyValues_Specific( KeyValues *pKV )
{
	SETUP_HLSL_VS_Input info;

	info.bFlexDelta_enabled = !!pKV->GetInt( "enable_flex" );
	info.bNormal_enabled = !!pKV->GetInt( "enable_normal" );
	info.bNormal_enabled_compression = !!pKV->GetInt( "enable_normal_compression" );
	info.bBlendweights_enabled = !!pKV->GetInt( "enable_blendweights" );
	info.bTangentspace_enabled = !!pKV->GetInt( "enable_tangentspace" );
	info.bTangentspace_enabled_skinning = !!pKV->GetInt( "enable_tangentspace_skinning" );

	info.iTexcoords_num = pKV->GetInt( "numTexcoords" );
	info.iVertexcolor_num = pKV->GetInt( "numColor" );

	for ( int i = 0; i < 3; i++ )
		info.iDataTypeFlag_TexCoords[i] = pKV->GetInt( VarArgs( "dTFlag_Texcoords_%i", i ), HLSLVAR_FLOAT2 );
	for ( int i = 0; i < 2; i++ )
		info.iDataTypeFlag_Color[i] = pKV->GetInt( VarArgs( "dTFlag_Color_%i", i ), HLSLVAR_FLOAT4 );

	Setup( info );
}