void *CDmElementFramework::QueryInterface( const char *pInterfaceName )
{
	if ( !V_strcmp( pInterfaceName, VDMELEMENTFRAMEWORK_VERSION ) )
		return (IDmElementFramework*)this;

	return NULL;
}
void CFileListManager::OnSaveFileAs( KeyValues *pParams )
{
	int nSelected = GetSelectedItemsCount();
	Assert( nSelected == 1 );
	if ( nSelected != 1 )
		return;

	KeyValues *pContextKeyValues = new KeyValues( "OnSaveAs" );
	pContextKeyValues->SetInt( "itemId", GetSelectedItem( 0 ) );
	DmFileId_t fileid = ( DmFileId_t )GetItemUserData( GetSelectedItem( 0 ) );
	const char *pFileFormat = g_pDataModel->GetFileFormat( fileid );

	vgui::FileOpenDialog *pFileOpenDialog = new vgui::FileOpenDialog( this, "Save .dmx File As", false, pContextKeyValues );
	// if this control is moved to vgui_controls, change the default format to "dmx", the generic dmx format
	pFileOpenDialog->AddFilter( "*.dmx", "Generic MovieObjects File (*.dmx)", false, "movieobjects" );
	if ( V_strcmp( pFileFormat, "movieobjects" ) != 0 )
	{
		char description[ 256 ];
		V_snprintf( description, sizeof( description ), "%s (*.dmx)", g_pDataModel->GetFormatDescription( pFileFormat ) );
		pFileOpenDialog->AddFilter( "*.dmx", description, true, pFileFormat );
	}
	pFileOpenDialog->AddActionSignalTarget( this );
	pFileOpenDialog->SetDeleteSelfOnClose( true );
	pFileOpenDialog->DoModal( false );
}
Ejemplo n.º 3
0
bool CUtlString::IsEqual_CaseSensitive( const char *src ) const
{
	if ( !src )
	{
		return (Length() == 0);
	}
	return ( V_strcmp( Get(), src ) == 0 );
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: Checks if building this mesh is disabled
//-----------------------------------------------------------------------------
bool CRecastMgr::IsMeshBuildDisabled( const char *meshName )
{
	CRecastMgrEnt *pMgrEnt = GetRecastMgrEnt();
	if( pMgrEnt )
	{
		if( pMgrEnt->HasSpawnFlags( SF_DISABLE_MESH_HUMAN ) && V_strcmp( "human", meshName ) == 0 )
			return true;
		else if( pMgrEnt->HasSpawnFlags( SF_DISABLE_MESH_MEDIUM ) && V_strcmp( "medium", meshName ) == 0 )
			return true;
		else if( pMgrEnt->HasSpawnFlags( SF_DISABLE_MESH_LARGE ) && V_strcmp( "large", meshName ) == 0 )
			return true;
		else if( pMgrEnt->HasSpawnFlags( SF_DISABLE_MESH_VERYLARGE ) && V_strcmp( "verylarge", meshName ) == 0 )
			return true;
		else if( pMgrEnt->HasSpawnFlags( SF_DISABLE_MESH_AIR ) && V_strcmp( "air", meshName ) == 0 )
			return true;
	}
	return false;
}
bool CommandMenu::CheckRules(const char *rule, const char *ruledata)
{
	if ( !rule  || !ruledata )
	{
		return true; // no rule defined, show item
	}

	if ( V_strcmp( rule, "team") == 0 )
	{
		// if team is same as specified in rule, show item
		return ( V_strcmp( m_CurrentTeam, ruledata ) == 0 );
	}
	else if ( V_strcmp( rule, "map") == 0 )
	{
		// if team is same as specified in rule, show item
		return ( Q_strcmp( m_CurrentMap, ruledata ) == 0 );
	}

	return true;
}
Ejemplo n.º 6
0
boost::python::object PyGetClassByClassname( const char *class_name )
{
	if( !class_name )
		return bp::object();

	PyEntityFactory *p = g_pPyEntityFactoryHead;
	while( p )
	{
		if( !V_strcmp( p->GetClassname(), class_name ) )
		{
			return p->GetClass();
		}
		p = p->m_pPyNext;
	}
	// Throw exception?
	return bp::object();
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: VERSION 1.0 parser, need to implement new ones if 
//  file format changes!!!
// Input  : buf - 
//-----------------------------------------------------------------------------
void CSentence::ParseDataVersionOnePointZero( CUtlBuffer& buf )
{
	char token[ 4096 ];

	while ( 1 )
	{
		buf.GetString( token );
		if ( strlen( token ) <= 0 )
			break;
		
		// end of block, return
		if ( !V_strcmp( token, "}" ) )
			break;

		char section[ 256 ];
		Q_strncpy( section, token, sizeof( section ) );

		buf.GetString( token );
		if ( stricmp( token, "{" ) )
			break;

		if ( !stricmp( section, "PLAINTEXT" ) )
		{
			ParsePlaintext( buf );
		}
		else if ( !stricmp( section, "WORDS" ) )
		{
			ParseWords( buf );
		}
		else if ( !stricmp( section, "EMPHASIS" ) )
		{
			ParseEmphasis( buf );
		}		
		else if ( !stricmp( section, "CLOSECAPTION" ) )
		{
			// NOTE:  CLOSECAPTION IS NO LONGER VALID
			// This just skips the section of data.
			ParseCloseCaption( buf );
		}
		else if ( !stricmp( section, "OPTIONS" ) )
		{
			ParseOptions( buf );
		}
	}
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *tempVal - 
//-----------------------------------------------------------------------------
void ConVar::ChangeStringValue( const char *tempVal, float flOldValue )
{
	Assert( !( m_nFlags & FCVAR_NEVER_AS_STRING ) );

 	char* pszOldValue = (char*)stackalloc( m_StringLength );
	memcpy( pszOldValue, m_pszString, m_StringLength );
	
	if ( tempVal )
	{
		int len = Q_strlen(tempVal) + 1;

		if ( len > m_StringLength)
		{
			if (m_pszString)
			{
				delete[] m_pszString;
			}

			m_pszString	= new char[len];
			m_StringLength = len;
		}

		memcpy( m_pszString, tempVal, len );
	}
	else 
	{
		*m_pszString = 0;
	}

	// If nothing has changed, don't do the callbacks.
	if (V_strcmp(pszOldValue, m_pszString) != 0)
	{
		// Invoke any necessary callback function
		if ( m_fnChangeCallback )
		{
			m_fnChangeCallback( this, pszOldValue, flOldValue );
		}

		g_pCVar->CallGlobalChangeCallbacks( this, pszOldValue, flOldValue );
	}

	stackfree( pszOldValue );
}
Ejemplo n.º 9
0
	virtual void DeleteOldRecordings(int nMax)
	{
		// this is O(n^2) with the number of demos, but I'm assuming people won't accumulate a million demos and then change the maximum to 1 so it'll be closer to O(n).

		while (true)
		{
			int nCount = 0;
			char szOldest[MAX_PATH];
			szOldest[0] = '\0';

			FileFindHandle_t ffh;
			for (const char *pszFile = filesystem->FindFirstEx("aswauto-*.dem", "MOD", &ffh); pszFile; pszFile = filesystem->FindNext(ffh))
			{
				nCount++;
				if (szOldest[0] == '\0' || V_strcmp(szOldest, pszFile) > 0)
				{
					V_strncpy(szOldest, pszFile, MAX_PATH);
				}
			}
			filesystem->FindClose(ffh);

			if (nCount == 0)
				return;
			if (nCount <= nMax)
				return;

			Msg("Deleting oldest recording: %s\n", szOldest);
			filesystem->RemoveFile(szOldest, "MOD");
			if (filesystem->FileExists(szOldest, "MOD"))
			{
				Warning("Deletion failed!\n");
				return;
			}
			Msg("%d recordings remaining.\n", nCount - 1);
		}
	}
Ejemplo n.º 10
0
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CAmbientGeneric::Activate( void )
{
	BaseClass::Activate();

	// Initialize sound source.  If no source was given, or source can't be found
	// then this is the source
	if (m_hSoundSource == NULL)
	{
		if (m_sSourceEntName != NULL_STRING)
		{
			m_hSoundSource = gEntList.FindEntityByName( NULL, m_sSourceEntName );
			if ( m_hSoundSource != NULL )
			{
				m_nSoundSourceEntIndex = m_hSoundSource->entindex();
			}
		}

		if (m_hSoundSource == NULL)
		{
			m_hSoundSource = this;
			m_nSoundSourceEntIndex = entindex();
		}
		else
		{
			if ( !FBitSet( m_spawnflags, SF_AMBIENT_SOUND_EVERYWHERE ) )
			{
				AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
			}
		}
	}

#ifdef PORTAL
		// This is the only way we can silence the radio sound from the first room without touching them map -- jdw
		if ( PortalGameRules() && PortalGameRules()->ShouldRemoveRadio() )
		{		
			if ( V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_00" ) == 0 || 
			    V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_11" ) == 0 || 
			    V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_14" ) == 0 )
			{
				if ( V_strcmp( STRING( GetEntityName() ), "radio_sound" ) == 0 )
				{
					UTIL_Remove( this );
					return;
				}
			}
		}
#endif // PORTAL

	// If active start the sound
	if ( m_fActive )
	{
		int flags = SND_SPAWNING;
		// If we are loading a saved game, we can't write into the init/signon buffer here, so just issue
		//  as a regular sound message...
		if ( gpGlobals->eLoadType == MapLoad_Transition ||
			 gpGlobals->eLoadType == MapLoad_LoadGame || 
			 g_pGameRules->InRoundRestart() )
		{
			flags = SND_NOFLAGS;
		}
	
		// Tracker 76119:  8/12/07 ywb: 
		//  Make sure pitch and volume are set up to the correct value (especially after restoring a .sav file)
		flags |= ( SND_CHANGE_PITCH | SND_CHANGE_VOL );  

		// Don't bother sending over to client if volume is zero, though
		if ( m_dpv.vol > 0 )
		{
			SendSound( (SoundFlags_t)flags );
		}

		SetNextThink( gpGlobals->curtime + 0.1f );
	}
}
Ejemplo n.º 11
0
HSCRIPT VScriptCompileScript( const char *pszScriptName, bool bWarnMissing )
{
    if ( !g_pScriptVM )
    {
        return NULL;
    }

    static const char *pszExtensions[] =
    {
        "",		// SL_NONE
        ".gm",	// SL_GAMEMONKEY
        ".nut",	// SL_SQUIRREL
        ".lua", // SL_LUA
        ".py",  // SL_PYTHON
    };

    const char *pszVMExtension = pszExtensions[g_pScriptVM->GetLanguage()];
    const char *pszIncomingExtension = V_strrchr( pszScriptName , '.' );
    if ( pszIncomingExtension && V_strcmp( pszIncomingExtension, pszVMExtension ) != 0 )
    {
        Log_Warning( LOG_VScript, "Script file type does not match VM type\n" );
        return NULL;
    }

    CFmtStr scriptPath;
    if ( pszIncomingExtension )
    {
        scriptPath.sprintf( "scripts/vscripts/%s", pszScriptName );
    }
    else
    {
        scriptPath.sprintf( "scripts/vscripts/%s%s", pszScriptName,  pszVMExtension );
    }

    const char *pBase;
    CUtlBuffer bufferScript;

    if ( g_pScriptVM->GetLanguage() == SL_PYTHON )
    {
        // python auto-loads raw or precompiled modules - don't load data here
        pBase = NULL;
    }
    else
    {
        bool bResult = filesystem->ReadFile( scriptPath, "GAME", bufferScript );

        if( !bResult )
        {
            Log_Warning( LOG_VScript, "Script not found (%s) \n", scriptPath.operator const char *() );
            Assert( "Error running script" );
        }

        pBase = (const char *) bufferScript.Base();

        if ( !pBase || !*pBase )
        {
            return NULL;
        }
    }


    const char *pszFilename = V_strrchr( scriptPath, '/' );
    pszFilename++;
    HSCRIPT hScript = g_pScriptVM->CompileScript( pBase, pszFilename );
    if ( !hScript )
    {
        Log_Warning( LOG_VScript, "FAILED to compile and execute script file named %s\n", scriptPath.operator const char *() );
        Assert( "Error running script" );
    }
    return hScript;
}
void CNB_Skill_Panel::OnThink()
{
	BaseClass::OnThink();

	if ( !MarineSkills() || !Briefing() )
		return;

	CASW_Marine_Profile *pProfile = Briefing()->GetMarineProfileByProfileIndex( m_nProfileIndex );
	if ( !pProfile )
		return;

	int nMaxSkillPoints = MarineSkills()->GetMaxSkillPoints( pProfile->GetSkillMapping( m_nSkillSlot ) );
	const char *szImageName = MarineSkills()->GetSkillImage( pProfile->GetSkillMapping( m_nSkillSlot ) );
	if ( V_strcmp( m_szLastSkillImage, szImageName ) )
	{
		V_snprintf( m_szLastSkillImage, sizeof( m_szLastSkillImage ), "%s", szImageName );
		char buffer[ 256 ];
		V_snprintf( buffer, sizeof( buffer ), "vgui/%s", szImageName );
		
		color32 white;
		white.r = 255;
		white.g = 255;
		white.b = 255;
		white.a = 255;

		color32 dull;
		dull.r = 192;
		dull.g = 192;
		dull.b = 192;
		dull.a = 255;

		m_pSkillButton->SetImage( CBitmapButton::BUTTON_ENABLED, buffer, white );
		m_pSkillButton->SetImage( CBitmapButton::BUTTON_DISABLED, buffer, dull );
		m_pSkillButton->SetImage( CBitmapButton::BUTTON_PRESSED, buffer, white );

		V_snprintf( buffer, sizeof( buffer ), "vgui/%s_over", szImageName );
		m_pSkillButton->SetImage( CBitmapButton::BUTTON_ENABLED_MOUSE_OVER, buffer, white );		
	}
	m_pSkillButton->SetEnabled( m_bSpendPointsMode && CanSpendPoint() );

	m_pSkillLabel->SetText( MarineSkills()->GetSkillName( pProfile->GetSkillMapping( m_nSkillSlot ) ) );

	wchar_t wszPointsBuffer[ 24 ];
	_snwprintf( wszPointsBuffer, sizeof( wszPointsBuffer ), L"%d / %d", m_nSkillPoints, nMaxSkillPoints );
	m_pSkillNumberLabel->SetText( wszPointsBuffer );

	m_pSkillBar->ClearMinMax();
	m_pSkillBar->AddMinMax( 0, nMaxSkillPoints );
	m_pSkillBar->Init( m_nSkillPoints, m_nSkillPoints, 0.1f, true, false );

	if ( IsCursorOver() )
	{
		if (!g_hBriefingTooltip.Get())
		{
			g_hBriefingTooltip = new BriefingTooltip(GetParent(), "MedalsTooltip");
		}	
		else if ( g_hBriefingTooltip->GetParent() != GetParent() )
		{
			g_hBriefingTooltip->SetParent( GetParent() );
		}

		if ( g_hBriefingTooltip.Get() && IsFullyVisible() &&
			g_hBriefingTooltip.Get()->GetTooltipPanel() != this )
		{	
			int tx, ty, w, h;
			tx = ty = 0;
			LocalToScreen(tx, ty);
			GetSize(w, h);
			tx += w * 0.5f;
			ty -= h * 0.01f;

			g_hBriefingTooltip.Get()->SetTooltip( this, MarineSkills()->GetSkillName( pProfile->GetSkillMapping( m_nSkillSlot ) ), MarineSkills()->GetSkillDescription( pProfile->GetSkillMapping( m_nSkillSlot ) ),
				tx, ty );
		}
	}
}