示例#1
0
void CDevMapPanel::OnCommand(const char *command)
{
	if (!Q_strcmp(command, "Load") || !Q_strcmp(command, "DoubleClick") || !Q_strcmp(command, "PressedEnter"))
	{
		int itemId = m_pListPanel->GetSelectedItem(0);
		KeyValues *kv = m_pListPanel->GetItem(itemId);
		if (kv)
		{
			const char *map = kv->GetString("Map");
			char map_command[64];
			Q_snprintf(map_command, sizeof(map_command), "map %s", map);
			engine->ClientCmd("scene_flush");
			engine->ClientCmd("disconnect");
			engine->ClientCmd("mat_fullbright 0");
			engine->ClientCmd("progress_enable");
			engine->ClientCmd("clear");
			engine->ClientCmd(map_command);
		}
	}
	else if (!Q_strcmp(command, "Refresh"))
	{
		AddMapsToPanel();
	}

	BaseClass::OnCommand(command);
}
示例#2
0
//-----------------------------------------------------------------------------
// Purpose: Loads the surface properties database into the physics DLL
//-----------------------------------------------------------------------------
void LoadSurfaceProperties( void )
{
	CreateInterfaceFn physicsFactory = GetPhysicsFactory();
	if ( !physicsFactory )
		return;

	physprops = (IPhysicsSurfaceProps *)physicsFactory( VPHYSICS_SURFACEPROPS_INTERFACE_VERSION, NULL );

	const char *SURFACEPROP_MANIFEST_FILE = "scripts/surfaceproperties_manifest.txt";
	KeyValues *manifest = new KeyValues( SURFACEPROP_MANIFEST_FILE );
	if ( manifest->LoadFromFile( g_pFileSystem, SURFACEPROP_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				LoadSurfacePropFile( sub->GetString() );
				continue;
			}
		}
	}

	manifest->deleteThis();
}
//-----------------------------------------------------------------------------
// Purpose: get the "idle" animation to play as the compliment to the movement animation
//-----------------------------------------------------------------------------
int CAI_BlendedMotor::GetInteriorSequence( int fromSequence )
{
	// FIXME: add interior activity to path, just like arrival activity.
	int  sequence = GetNavigator()->GetMovementSequence();

	if (m_nInteriorSequence != ACT_INVALID && sequence == m_nPrevMovementSequence)
	{
		return m_nInteriorSequence;
	}

	m_nPrevMovementSequence = sequence;

	KeyValues *seqKeyValues = GetOuter()->GetSequenceKeyValues( sequence );
	// Msg("sequence %d : %s (%d)\n", sequence,  GetOuter()->GetSequenceName( sequence ), seqKeyValues != NULL );
	if (seqKeyValues)
	{
		KeyValues *pkvInterior = seqKeyValues->FindKey("interior");
		if (pkvInterior)
		{
			const char *szActivity = pkvInterior->GetString();
		
			Activity activity = ( Activity )GetOuter()->LookupActivity( szActivity );
			if ( activity != ACT_INVALID )
			{
				m_nInteriorSequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( activity ), fromSequence );
			}
			else
			{
				activity = (Activity)GetOuter()->GetActivityID( szActivity );
				if ( activity != ACT_INVALID )
				{
					m_nInteriorSequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( activity ), fromSequence );
				}
			}

			if (activity == ACT_INVALID || m_nInteriorSequence == ACT_INVALID)
			{
				m_nInteriorSequence = GetOuter()->LookupSequence( szActivity );
			}
		}
	}

	if (m_nInteriorSequence == ACT_INVALID)
	{
		Activity activity = GetNavigator()->GetMovementActivity();
		if (activity == ACT_WALK_AIM || activity == ACT_RUN_AIM)
		{
			activity = ACT_IDLE_ANGRY;
		}
		else
		{
			activity = ACT_IDLE;
		}
		m_nInteriorSequence = GetOuter()->SelectWeightedSequence( GetOuter()->TranslateActivity( activity ), fromSequence );

		Assert( m_nInteriorSequence != ACT_INVALID );
	}

	return m_nInteriorSequence;
}
CVGUIProjectable *CProjectableFactory::AllocateProjectableByScript( const char *pszFileName )
{
	CVGUIProjectable *pPanel = NULL;

	KeyValues *pKV = new KeyValues("");

	bool bSuccess = pKV->LoadFromFile( g_pFullFileSystem, VarArgs( "%s/%s", PATHLOCATION_PROJECTABLE_SCRIPTS, pszFileName ) );
	if ( !bSuccess )
		bSuccess = pKV->LoadFromFile( g_pFullFileSystem, VarArgs( "%s/%s.txt", PATHLOCATION_PROJECTABLE_SCRIPTS, pszFileName ) );

	if ( bSuccess )
	{
		const char *pszFactoryName = pKV->GetString( "factory" );

		if ( pszFactoryName != NULL && *pszFactoryName != '\0' )
			pPanel = AllocateProjectableByName( pszFactoryName );

		if ( pPanel != NULL )
		{
			KeyValues *pConfig = pKV->FindKey( "config" );

			if ( pConfig != NULL )
			{
				pPanel->LoadProjectableConfig( pConfig );
				pPanel->InvalidateLayout( true, true );
			}
		}
	}

	pKV->deleteThis();

	return pPanel;
}
//-----------------------------------------------------------------------------
// Purpose: Bind the specified keyname to the specified item
// Input  : *item - Item to which to add the key
//			*keyname - The key to be added
//-----------------------------------------------------------------------------
void COptionsSubKeyboard::AddBinding( KeyValues *item, const char *keyname )
{
	// See if it's already there as a binding
	if ( !stricmp( item->GetString( "Key", "" ), keyname ) )
		return;

	// Make sure it doesn't live anywhere
	RemoveKeyFromBindItems( item, keyname );

	const char *binding = item->GetString( "Binding", "" );

	// Loop through all the key bindings and set all entries that have
	// the same binding. This allows us to have multiple entries pointing 
	// to the same binding.
	for (int i = 0; i < m_pKeyBindList->GetItemCount(); i++)
	{
		KeyValues *curitem = m_pKeyBindList->GetItemData(m_pKeyBindList->GetItemIDFromRow(i));
		if ( !curitem )
			continue;

		const char *curbinding = curitem->GetString( "Binding", "" );

		if (!stricmp(curbinding, binding))
		{
			curitem->SetString( "Key", keyname );
			m_pKeyBindList->InvalidateItem(i);
		}
	}
}
示例#6
0
// sets priority of objective entities based on the order the rooms were listed in the mission/objective txt
void VMFExporter::ReorderObjectives( const CRoomTemplate *pTemplate, KeyValues *pTemplateKeys )
{
    KeyValues *pKeys = m_pTemplateKeys;
    while ( pKeys )
    {
        if ( !Q_stricmp( pKeys->GetName(), "entity" ) && !Q_strnicmp( pKeys->GetString( "classname" ), "asw_objective", 13 ) )
        {
            if ( pKeys->GetFloat( "Priority" ) != 0 )	// if level designer has already set priority, then don't override it
            {
                pKeys = pKeys->GetNextKey();
                continue;
            }

            int iPriority = 100;
            // We no longer have a requested rooms array, so this code is not valid.  Need to replace it with something else to ensure priorities are set correctly.
// 			for ( int i = 0; i < m_pMapLayout->m_pRequestedRooms.Count(); i++ )
// 			{
// 				if ( m_pMapLayout->m_pRequestedRooms[i]->m_pRoomTemplate == pTemplate )
// 				{
// 					iPriority = m_pMapLayout->m_pRequestedRooms[i]->m_iMissionTextOrder;
// 				}
// 			}
            pKeys->SetFloat( "Priority", iPriority );
        }
        pKeys = pKeys->GetNextKey();
    }
}
void ReadKVIdents_EConst( CUtlVector< SimpleEnvConstant* > &hList, KeyValues *pKV )
{
	int itr = 0;
	char tmp[MAX_PATH];
	Q_snprintf( tmp, MAX_PATH, "econst_%i", itr );
	KeyValues *c = pKV->FindKey( tmp );

	while( c )
	{
		SimpleEnvConstant *econst = new SimpleEnvConstant();

		econst->iEnvC_ID = c->GetInt( "i_envconstidx" );
		econst->iHLSLRegister = c->GetInt( "i_normregister" );
		econst->iConstSize = c->GetInt( "i_econstsize" );
		econst->iSmartNumComps = c->GetInt( "i_smartcomps" );

		const char *name = c->GetString( "sz_smartname" );
		int len = Q_strlen( name ) + 1;
		econst->szSmartHelper = new char[ len ];
		Q_snprintf( econst->szSmartHelper, MAX_PATH, "%s", name );

		for ( int i = 0; i < 4; i++ )
		{
			char tmpdef[MAX_PATH];
			Q_snprintf( tmpdef, MAX_PATH, "fl_smartdefault_%02i", i );
			econst->flSmartDefaultValues[ i ] = c->GetFloat( tmpdef );
		}

		hList.AddToTail( econst );
		itr++;
		Q_snprintf( tmp, MAX_PATH, "econst_%i", itr );
		c = pKV->FindKey( tmp );
	}
}
示例#8
0
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
bool CNPC_Furniture::CreateVPhysics( void )
{
#ifndef HL2_DLL
	return false;
#endif

	if ( !m_BoneFollowerManager.GetNumBoneFollowers() )
	{
		KeyValues *modelKeyValues = new KeyValues("");
		if ( modelKeyValues->LoadFromBuffer( modelinfo->GetModelName( GetModel() ), modelinfo->GetModelKeyValueText( GetModel() ) ) )
		{
			// Do we have a bone follower section?
			KeyValues *pkvBoneFollowers = modelKeyValues->FindKey("bone_followers");
			if ( pkvBoneFollowers )
			{
				// Loop through the list and create the bone followers
				KeyValues *pBone = pkvBoneFollowers->GetFirstSubKey();
				while ( pBone )
				{
					// Add it to the list
					const char *pBoneName = pBone->GetString();
					m_BoneFollowerManager.AddBoneFollower( this, pBoneName );

					pBone = pBone->GetNextKey();
				}
			}
		}
		modelKeyValues->deleteThis();
	}

	return true;
}
//-----------------------------------------------------------------------------
// Purpose: sets the value of a variable in the list
//-----------------------------------------------------------------------------
void CVarListPropertyPage::SetVarString(const char *varName, const char *value)
{
	// find the item by name
	int itemID = m_pRulesList->GetItem(varName);
	KeyValues *rule = m_pRulesList->GetItem(itemID);
	if (!rule)
		return;

	// parse the rule
	const char *type = rule->GetString("type");
	if (!stricmp(type, "enumeration"))
	{
		// look up the value in the enumeration
		int iValue = atoi(value);
		const char *result = rule->FindKey("list", true)->GetString(value, "");
		rule->SetString("value", result);
		rule->SetInt("enum", iValue);
	}
	else 
	{
		// no special type, treat it as a string
		rule->SetString("value", value);
	}
		
	m_pRulesList->ApplyItemChanges(itemID);
}
//-----------------------------------------------------------------------------
// Returns the selected sound
//-----------------------------------------------------------------------------
const char *CSoundPicker::GetSelectedSoundName( int nSelectionIndex )
{
	if ( m_pGameSoundPage && ( m_pViewsSheet->GetActivePage() == m_pGameSoundPage ) )
	{
		int nCount = m_pGameSoundList->GetSelectedItemsCount();
		if ( nCount == 0 )
			return NULL;

		if ( nSelectionIndex < 0 )
		{
			nSelectionIndex = nCount - 1;
		}
		int nIndex = m_pGameSoundList->GetSelectedItem( nSelectionIndex );
		if ( nIndex >= 0 )
		{
			KeyValues *pkv = m_pGameSoundList->GetItem( nIndex );
			return pkv->GetString( "gamesound", NULL );
		}
		return NULL;
	}

	if ( m_pWavPage && ( m_pViewsSheet->GetActivePage() == m_pWavPage ) )
		return GetSelectedAsset( nSelectionIndex );

	return NULL;
}
示例#11
0
//--------------------------------------------------------------------------------------------------------------
void DownloadCache::GetCachedData( RequestContext *rc )
{
	if ( !m_cache )
		return;

	char cachePath[_MAX_PATH];
	GetCacheFilename( rc, cachePath );

	if ( !(*cachePath) )
		return;

	FileHandle_t fp = g_pFileSystem->Open( cachePath, "rb" );

	if ( fp == FILESYSTEM_INVALID_HANDLE )
		return;

	int size = g_pFileSystem->Size(fp);
	rc->cacheData = new unsigned char[size];
	int status = g_pFileSystem->Read( rc->cacheData, size, fp );
	g_pFileSystem->Close( fp );
	if ( !status )
	{
		delete[] rc->cacheData;
		rc->cacheData = NULL;
	}
	else
	{
		BuildKeyNames( rc->gamePath );
		rc->nBytesCached = size;
		strncpy( rc->cachedTimestamp, m_cache->GetString( m_timestampKey, "" ), BufferSize );
	}
}
//-----------------------------------------------------------------------------
// Purpose: creates the full path for a node
//-----------------------------------------------------------------------------
void DirectorySelectDialog::GenerateFullPathForNode(int nodeIndex, char *path, int pathBufferSize)
{
	// get all the nodes
	CUtlLinkedList<int, int> nodes;
	nodes.AddToTail(nodeIndex);
	int parentIndex = nodeIndex;
	while (1)
	{
		parentIndex = m_pDirTree->GetItemParent(parentIndex);
		if (parentIndex == -1)
			break;
		nodes.AddToHead(parentIndex);
	}

	// walk the nodes, adding to the path
	path[0] = 0;
	bool bFirst = true;
	FOR_EACH_LL( nodes, i )
	{
		KeyValues *kv = m_pDirTree->GetItemData( nodes[i] );
		strcat(path, kv->GetString("Text"));

		if (!bFirst)
		{
			strcat(path, "\\");
		}
		bFirst = false;
	}
示例#13
0
//-----------------------------------------------------------------------------
// Purpose: Handles changes to combo boxes
//-----------------------------------------------------------------------------
void CMOMSpectatorMenu::OnTextChanged(KeyValues *data)
{
    Panel *panel = reinterpret_cast<Panel *>(data->GetPtr("panel"));

    ComboBox *box = dynamic_cast<ComboBox *>(panel);

    if (box == m_pConfigSettings) // don't change the text in the config setting combo
    {
        m_pConfigSettings->SetText("#Spec_Options");
    }
    else if (box == m_pPlayerList)
    {
        KeyValues *kv = box->GetActiveItemUserData();
        if (kv && GameResources())
        {
            const char *player = kv->GetString("player");

            int currentPlayerNum = GetSpectatorTarget();
            const char *currentPlayerName = GameResources()->GetPlayerName(currentPlayerNum);

            if (!FStrEq(currentPlayerName, player))
            {
                char command[128];
                Q_snprintf(command, sizeof(command), "spec_player \"%s\"", player);
                engine->ClientCmd(command);
            }
        }
    }
}
void ReadKVIdents_Combos( CUtlVector< SimpleCombo* > &hList, KeyValues *pKV )
{
	int itr = 0;
	char tmp[MAX_PATH];
	Q_snprintf( tmp, MAX_PATH, "combo_%i", itr );
	KeyValues *c = pKV->FindKey( tmp );

	while( c )
	{
		SimpleCombo *combo = new SimpleCombo();

		const char *name = c->GetString( "sz_name" );
		int len = Q_strlen( name ) + 1;
		combo->name = new char[ len ];
		Q_snprintf( combo->name, MAX_PATH, "%s", name );

		combo->bStatic = !!c->GetInt( "i_static" );
		combo->min = c->GetInt( "i_min" );
		combo->max = c->GetInt( "i_max" );
		combo->iComboType = c->GetInt( "i_type" );

		hList.AddToTail( combo );
		itr++;
		Q_snprintf( tmp, MAX_PATH, "combo_%i", itr );
		c = pKV->FindKey( tmp );
	}
}
示例#15
0
//-----------------------------------------------------------------------------
// Purpose: loads filter settings (from disk) from the keyvalues
//-----------------------------------------------------------------------------
void CBaseMapsPage::LoadFilterSettings()
{
    KeyValues *filter = MapSelectorDialog().GetFilterSaveData(GetName());

    //Game-mode selection
    m_iGameModeFilter = filter->GetInt("gamemode", 0);
    m_pGameModeFilter->ActivateItemByRow(m_iGameModeFilter);

    //"Map"
    Q_strncpy(m_szMapFilter, filter->GetString("map"), sizeof(m_szMapFilter));
    m_pMapFilter->SetText(m_szMapFilter);

    //Map layout
    m_iMapLayoutFilter = filter->GetInt("maplayout", 0);
    m_pMapLayoutFilter->ActivateItemByRow(m_iMapLayoutFilter);

    //HideCompleted maps
    m_bFilterHideCompleted = filter->GetBool("HideCompleted", false);
    m_pHideCompletedFilterCheck->SetSelected(m_bFilterHideCompleted);

    //Difficulty
    m_iDifficultyFilter = filter->GetInt("difficulty");
    if (m_iDifficultyFilter)
    {
        char buf[32];
        Q_snprintf(buf, sizeof(buf), "< %d", m_iDifficultyFilter);
        m_pDifficultyFilter->SetText(buf);
    }

    // apply to the controls
    OnLoadFilter(filter);
    UpdateFilterSettings();
    ApplyGameFilters();
}
示例#16
0
//-----------------------------------------------------------------------------
// Purpose: Loads additional commandline arguments from a config file for an app.
//			Filesystem must be initialized before calling this function.
// keyname: Name of the block containing the key/args pairs (ie map or model name)
// appname: Keyname for the commandline arguments to be loaded - typically the exe name.
//-----------------------------------------------------------------------------
void LoadCmdLineFromFile( int &argc, char **&argv, const char *keyname, const char *appname )
{
	sFoundConfigArgs = false;

	Assert( g_pFileSystem );
	if( !g_pFileSystem )
		return;

	// Load the cfg file, and find the keyname
	KeyValues *kv = new KeyValues( "CommandLine" );

	char filename[512];
	Q_snprintf( filename, sizeof( filename ), "%s/cfg/commandline.cfg", gamedir );

	if ( kv->LoadFromFile( g_pFileSystem, filename ) )
	{
		// Load the commandline arguments for this app
		KeyValues  *appKey	= kv->FindKey( keyname );
		if( appKey )
		{
			const char *str	= appKey->GetString( appname );
			Msg( "Command Line found: %s\n", str );

			AddArguments( argc, argv, str );
		}
	}

	kv->deleteThis();
}
示例#17
0
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey )
{
	if ( m_WeaponInfoDatabase.Count() )
		return;

	KeyValues *manifest = new KeyValues( "weaponscripts" );
	if ( manifest->LoadFromFile( filesystem, "scripts/weapon_manifest.txt", "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL ; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				char fileBase[512];
				Q_FileBase( sub->GetString(), fileBase, sizeof(fileBase) );
				WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
				if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
				{
					gWR.LoadWeaponSprites( tmp );
				}
#else
				ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
			}
			else
			{
				Error( "Expecting 'file', got %s\n", sub->GetName() );
			}
		}
	}
	manifest->deleteThis();
}
int CTilegenKVEditorPage::RecursiveCreateFolderNodes( int iParentIndex, char *szFilename )
{
	char* szFolder = (char*) Q_strnchr( szFilename, CORRECT_PATH_SEPARATOR, Q_strlen( szFilename ) );
	if ( !szFolder )
	{
		return iParentIndex;
	}

	*szFolder = 0;	
	// check if szFilename node exists already
	for ( int i = 0; i < m_pTree->GetNumChildren( iParentIndex ); i++ )
	{
		int iChild = m_pTree->GetChild( iParentIndex, i );
		KeyValues *pKV = m_pTree->GetItemData( iChild );
		if ( !Q_stricmp( szFilename, pKV->GetString( "Text" ) ) )
		{
			return iChild;
		}
	}
	KeyValues *pFolderEntry = new KeyValues("FolderEntry");
	pFolderEntry->SetString( "Text", szFilename );
	int iItem = m_pTree->AddItem( pFolderEntry, iParentIndex );
	m_pTree->SetItemFgColor( iItem, Color(128, 128, 128, 255) );
	return RecursiveCreateFolderNodes( iItem, szFolder + 1 );
}
//-----------------------------------------------------------------------------
// Purpose: User clicked on item: remember where last active row/column was
//-----------------------------------------------------------------------------
void COptionsSubKeyboard::ItemSelected(int itemID)
{
	m_pKeyBindList->SetItemOfInterest(itemID);

	if (m_pKeyBindList->IsItemIDValid(itemID))
	{
		// find the details, see if we should be enabled/clear/whatever
		m_pSetBindingButton->SetEnabled(true);

		KeyValues *kv = m_pKeyBindList->GetItemData(itemID);
		if (kv)
		{
			const char *key = kv->GetString("Key", NULL);
			if (key && *key)
			{
				m_pClearBindingButton->SetEnabled(true);
			}
			else
			{
				m_pClearBindingButton->SetEnabled(false);
			}

			if (kv->GetInt("Header"))
			{
				m_pSetBindingButton->SetEnabled(false);
			}
		}
	}
	else
	{
		m_pSetBindingButton->SetEnabled(false);
		m_pClearBindingButton->SetEnabled(false);
	}
}
示例#20
0
void PhysParseSurfaceData( IPhysicsSurfaceProps *pProps, IFileSystem *pFileSystem )
{
	KeyValues *manifest = new KeyValues( SURFACEPROP_MANIFEST_FILE );
	if ( manifest->LoadFromFile( pFileSystem, SURFACEPROP_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				AddSurfacepropFile( sub->GetString(), pProps, pFileSystem );
				continue;
			}

			Warning( "surfaceprops::Init:  Manifest '%s' with bogus file type '%s', expecting 'file'\n", 
				SURFACEPROP_MANIFEST_FILE, sub->GetName() );
		}
	}
	else
	{
		Error( "Unable to load manifest file '%s'\n", SURFACEPROP_MANIFEST_FILE );
	}

	manifest->deleteThis();
}
//-----------------------------------------------------------------------------
// initialization
//-----------------------------------------------------------------------------
bool CEntityTeamImagePanel::Init( KeyValues* pInitData, C_BaseEntity* pEntity )
{
	if (!BaseClass::Init( pInitData, pEntity))
		return false;

	if ( pInitData->GetInt( "showinnormalmode", 0 ) )
	{
		m_bShowInNormal = true;
	}

	// get the size...
	int w, h;
	if (!ParseCoord( pInitData, "offset", m_OffsetX, m_OffsetY ))
		return false;

	if (!ParseCoord( pInitData, "size", w, h ))
		return false;

	// Set the size...
	SetSize( w, h );

	m_iOrgWidth = w;
	m_iOrgHeight = h;
	m_iOrgOffsetX = m_OffsetX;
	m_iOrgOffsetY = m_OffsetY;

	const char *mouseover = pInitData->GetString( "mousehint", "" );
	if ( mouseover && mouseover[ 0 ] )
	{
		Q_strncpy( m_szMouseOverText, mouseover, sizeof( m_szMouseOverText ) );
	}

	for ( int i = 0 ; i < MAX_TEAMS; i++ )
	{
		char teamname[ 32 ];
		Q_snprintf( teamname, sizeof( teamname ), "Team%i", i );

		memset( &m_Images[ i ], 0, sizeof( m_Images[ i ] ) );

		// Look for team section
		KeyValues *pTeamKV = pInitData->FindKey( teamname );
		if ( !pTeamKV )
			continue;

		// modulation color
		if (!ParseRGBA( pTeamKV, "color", m_Images[i].m_r, m_Images[i].m_g, m_Images[i].m_b, m_Images[i].m_a ))
			return false;

		char const* pClassImage = pTeamKV->GetString( "material" );
		if ( !pClassImage || !pClassImage[ 0 ] )
			return false;

		// hook in the bitmap
		m_Images[ i ].m_pImage = new BitmapImage( GetVPanel(), pClassImage );
	}

	// we need updating
	vgui::ivgui()->AddTickSignal( GetVPanel() );
	return true;
}
示例#22
0
bool CInstanceSpawn::LoadFromKeyValues( KeyValues *pKeyValues )
{
	const char *pFilename = pKeyValues->GetString( "filename", NULL );
	if ( pFilename == NULL )
	{
		Log_Warning( LOG_TilegenLayoutSystem, "No 'filename' specified in CInstanceSpawn block.\n" );
		return false;
	}
	Q_strncpy( m_InstanceFilename, pFilename, _countof( m_InstanceFilename ) );

	const char *pType = pKeyValues->GetString( "type", NULL );
	if ( pType == NULL )
	{
		Log_Warning( LOG_TilegenLayoutSystem, "No 'type' specified in CInstanceSpawn block.\n" );
		return false;
	}
	else
	{
		if ( Q_stricmp( pType, "add_at_random_node" ) == 0 )
		{
			m_InstanceSpawningMethod = ISM_ADD_AT_RANDOM_NODE;
		}
		else
		{
			Log_Warning( LOG_TilegenLayoutSystem, "Invalid 'type' specified in CInstanceSpaw block.\n" );
			return false;
		}
	}

	m_nPlacedRoomIndex = pKeyValues->GetInt( "room_index", -1 );
	m_nRandomSeed = pKeyValues->GetInt( "random_seed", 0 );

	for ( KeyValues *pReplaceKV = pKeyValues->GetFirstSubKey(); pReplaceKV != NULL; pReplaceKV = pReplaceKV->GetNextKey() )
	{
		if ( Q_stricmp( pReplaceKV->GetName(), "key_value" ) == 0 )
		{
			const char *pKey = pReplaceKV->GetString( "key", "" );
			const char *pValue = pReplaceKV->GetString( "value", "" );

			int nIndex = m_AdditionalKeyValues.AddToTail();
			Q_strncpy( m_AdditionalKeyValues[nIndex].m_Key, pKey, MAX_TILEGEN_IDENTIFIER_LENGTH );
			Q_strncpy( m_AdditionalKeyValues[nIndex].m_Value, pValue, MAX_TILEGEN_IDENTIFIER_LENGTH );
		}
	}

	return true;
}
示例#23
0
//-----------------------------------------------------------------------------
// Purpose: adds all the font specifications to the surface
//-----------------------------------------------------------------------------
void CScheme::LoadFonts()
{
	// add our custom fonts
	for (KeyValues *kv = m_pData->FindKey("CustomFontFiles", true)->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
	{
		const char *fontFile = kv->GetString();
		if (fontFile && *fontFile)
		{
			g_pSurface->AddCustomFontFile( fontFile );
		}
	}

	// add bitmap fonts
	for (KeyValues *kv = m_pData->FindKey("BitmapFontFiles", true)->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
	{
		const char *fontFile = kv->GetString();
		if (fontFile && *fontFile)
		{
			bool bSuccess = g_pSurface->AddBitmapFontFile( fontFile );
			if ( bSuccess )
			{
				// refer to the font by a user specified symbol
				g_pSurface->SetBitmapFontName( kv->GetName(), fontFile );
			}
		}
	}

	// create the fonts
	for (KeyValues *kv = m_pData->FindKey("Fonts", true)->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
	{
		for ( int i = 0; i < 2; i++ )
		{
			// create the base font
			bool proportionalFont = static_cast<bool>( i );
			const char *fontName = GetMungedFontName( kv->GetName(), tag, proportionalFont ); // first time it adds a normal font, and then a proportional one
			HFont font = g_pSurface->CreateFont();
			int j = m_FontAliases.AddToTail();
			m_FontAliases[j]._fontName = fontName;
			m_FontAliases[j]._trueFontName = kv->GetName();
			m_FontAliases[j]._font = font;
			m_FontAliases[j].m_bProportional = proportionalFont;
		}
	}

	// load in the font glyphs
	ReloadFontGlyphs();
}
示例#24
0
// Mouse is now over a droppable panel
void PropertySheet::OnDroppablePanelPaint( CUtlVector< KeyValues * >& msglist, CUtlVector< Panel * >& dragPanels )
{
	// Convert this panel's bounds to screen space
	int x, y, w, h;

	GetSize( w, h );

	int tabHeight = IsSmallTabs() ? 14 : 28;
	h = tabHeight + 4;

	x = y = 0;
	LocalToScreen( x, y );

	surface()->DrawSetColor( GetDropFrameColor() );
	// Draw 2 pixel frame
	surface()->DrawOutlinedRect( x, y, x + w, y + h );
	surface()->DrawOutlinedRect( x+1, y+1, x + w-1, y + h-1 );

	if ( !IsDroppable( msglist ) )
	{
		return;
	}

	if ( !_showTabs )
	{
		return;
	}

	// Draw a fake new tab...

	x = 0;
	y = 2;
	w = 1;
	h = tabHeight;

	int last = m_PageTabs.Count();
	if ( last != 0 )
	{
		m_PageTabs[ last - 1 ]->GetBounds( x, y, w, h );
	}

	// Compute left edge of "fake" tab

	x += ( w + 1 );

	// Compute size of new panel
	KeyValues *data = msglist[ 0 ];
	char const *text = data->GetString( "tabname", "" );
	Assert( text );

	PageTab *fakeTab = new PageTab( this, "FakeTab", text, NULL, _tabWidth, NULL, false );
	fakeTab->SetBounds( x, 4, w, tabHeight - 4 );
	fakeTab->SetFont( m_tabFont );
	SETUP_PANEL( fakeTab );
	fakeTab->Repaint();
	surface()->SolveTraverse( fakeTab->GetVPanel(), true );
	surface()->PaintTraverse( fakeTab->GetVPanel() );
	delete fakeTab;
}
示例#25
0
void CASWJukeboxPlaylist::LoadPlaylistKV()
{
	KeyValues *pKV = new KeyValues( "playlist" );
	if( pKV->LoadFromFile( filesystem, sz_PlaylistFilename ) )
	{
		// If the load succeeded, create the playlist
		for( KeyValues *sub = pKV->GetFirstSubKey(); sub != NULL; sub = sub->GetNextTrueSubKey() )
		{
			const char *szTrackName = sub->GetString("TrackName");
			const char *szHexName = sub->GetString("HexName");
			const char *szAlbum = sub->GetString("Album");
			const char *szArtist = sub->GetString("Artist");
			const char *szGenre = sub->GetString("Genre");
			AddMusicToPlaylist( szTrackName, szHexName, szAlbum, szArtist, szGenre );
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: Adds a new section to the scoreboard (i.e the team header)
//-----------------------------------------------------------------------------
void CClientScoreBoardDialog::AddSection(int teamType, VGuiLibraryTeamInfo_t *team_info)
{
	if (teamType == TEAM_YES)
	{
		KeyValues *kv = new KeyValues("data");

		// setup the team name
		wchar_t *teamName = localize()->Find(team_info->name);
		wchar_t name[64];
		wchar_t string1[1024];
		wchar_t wNumPlayers[6];
		_snwprintf(wNumPlayers, 6, L"%i", team_info->players);

		if (!teamName)
		{
			localize()->ConvertANSIToUnicode(team_info->name, name, sizeof(name));
			teamName = name;
		}
		if (team_info->players == 1)
		{
			localize()->ConstructString( string1, sizeof( string1 ), localize()->Find("#Player"), 2, teamName, wNumPlayers );
		}
		else
		{
			localize()->ConstructString( string1, sizeof( string1 ), localize()->Find("#Players"), 2, teamName, wNumPlayers );
		}
		m_pPlayerList->AddSection(m_iSectionId, "", StaticPlayerSortFunc);
		m_pPlayerList->AddColumnToSection(m_iSectionId, "name", string1, 0, scheme()->GetProportionalScaledValue(NAME_WIDTH) );

		kv->SetInt("frags", team_info->frags);
		kv->SetInt("deaths", team_info->deaths);
		kv->SetInt("ping", team_info->ping);

		m_pPlayerList->AddColumnToSection(m_iSectionId, "frags", kv->GetString("frags"), 0, scheme()->GetProportionalScaledValue(SCORE_WIDTH) );
		m_pPlayerList->AddColumnToSection(m_iSectionId, "deaths", kv->GetString("deaths"), 0, scheme()->GetProportionalScaledValue(DEATH_WIDTH) );
		m_pPlayerList->AddColumnToSection(m_iSectionId, "ping", kv->GetString("ping"), 0, scheme()->GetProportionalScaledValue(PING_WIDTH) );

		kv->deleteThis();
	}
	else if ( teamType == TEAM_SPECTATORS )
	{
		m_pPlayerList->AddSection(m_iSectionId, "");
		m_pPlayerList->AddColumnToSection(m_iSectionId, "name", "#Spectators", 0, 100);
	}
}
// parse the script file, setup index table
bool C_SoundscapeSystem::Init()
{
	m_loopingSoundId = 0;

	const char *mapname = MapName();
	const char *mapSoundscapeFilename = NULL;
	if ( mapname && *mapname )
	{
		mapSoundscapeFilename = VarArgs( "scripts/soundscapes_%s.txt", mapname );
	}

	KeyValues *manifest = new KeyValues( SOUNDSCAPE_MANIFEST_FILE );
	if ( filesystem->LoadKeyValues( *manifest, IFileSystem::TYPE_SOUNDSCAPE, SOUNDSCAPE_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				AddSoundScapeFile( sub->GetString() );
				if ( mapSoundscapeFilename && FStrEq( sub->GetString(), mapSoundscapeFilename ) )
				{
					mapSoundscapeFilename = NULL; // we've already loaded the map's soundscape
				}
				continue;
			}

			Warning( "C_SoundscapeSystem::Init:  Manifest '%s' with bogus file type '%s', expecting 'file'\n", 
				SOUNDSCAPE_MANIFEST_FILE, sub->GetName() );
		}

		if ( mapSoundscapeFilename && filesystem->FileExists( mapSoundscapeFilename ) )
		{
			AddSoundScapeFile( mapSoundscapeFilename );
		}
	}
	else
	{
		Error( "Unable to load manifest file '%s'\n", SOUNDSCAPE_MANIFEST_FILE );
	}

	manifest->deleteThis();

	return true;
}
示例#28
0
//=============================================================================
void CustomCampaigns::Activate()
{
	BaseClass::Activate();

	//
	// Show reminder to download legacy data (if necessary)
	//
	if ( GetLegacyData::CheckAndSeeIfShouldShow() )
	{
		CBaseModPanel::GetSingleton().OpenWindow( WT_GETLEGACYDATA, this, false );
	}
	m_ActiveControl = m_GplCustomCampaigns;

	m_GplCustomCampaigns->RemoveAllPanelItems();

	// Build a list of campaigns
	KeyValues *pAllMissions = g_pMatchExtSwarm->GetAllMissions();
	if ( !pAllMissions )
		return;

	char const *szGameMode = m_pDataSettings->GetString( "game/mode", "campaign" );

	for ( KeyValues *pMission = pAllMissions->GetFirstTrueSubKey(); pMission; pMission = pMission->GetNextTrueSubKey() )
	{
		// Skip builtin missions
		if ( pMission->GetInt( "builtin" ) )
			continue;

		m_hasAddonCampaign = true;

		// Check this campaign has chapters for this mode
		KeyValues *pFirstChapter = pMission->FindKey( CFmtStr( "modes/%s/1", szGameMode ) );
		if ( !pFirstChapter )
		{
			m_SomeAddonNoSupport = true;
			continue;
		}

		CustomCampaignListItem* panelItem = m_GplCustomCampaigns->AddPanelItem<CustomCampaignListItem>( "CustomCampaignListItem" );

		panelItem->SetParent( m_GplCustomCampaigns );
		panelItem->SetCustomCampaignName( pMission->GetString( "displaytitle" ) );
		panelItem->SetCampaignContext( pMission->GetString( "name" ) );
	}
}
//-----------------------------------------------------------------------------
// Purpose: gets back the value of a variable
//-----------------------------------------------------------------------------
const char *CVarListPropertyPage::GetVarString(const char *varName)
{
	int itemID = m_pRulesList->GetItem(varName);
	KeyValues *rule = m_pRulesList->GetItem(itemID);
	if (!rule)
		return "";

	return rule->GetString("value");
}
示例#30
0
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey )
{
	if ( m_WeaponInfoDatabase.Count() )
		return;

#if !defined( _XBOX )
	FileFindHandle_t findHandle;
	const char *pFilename = filesystem->FindFirstEx( "scripts/weapon_*.txt", IsXbox() ? "XGAME" : "GAME", &findHandle );
	while ( pFilename != NULL )
	{
		char fileBase[512];
		Q_FileBase( pFilename, fileBase, sizeof(fileBase) );
		WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
		if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
		{
			gWR.LoadWeaponSprites( tmp );
		}
#else
		ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
		pFilename = filesystem->FindNext( findHandle );
	}
	filesystem->FindClose( findHandle );
#else
#define WEAPON_SCRIPT_MANIFEST_FILE		"scripts/_weapon_manifest.txt"

	// Use a manifest file on the xbox
	KeyValues *manifest = new KeyValues( "weaponscripts" );
	if ( manifest->LoadFromFile( filesystem, WEAPON_SCRIPT_MANIFEST_FILE, "XGAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL ; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				char fileBase[512];
				Q_FileBase( sub->GetString(), fileBase, sizeof(fileBase) );
				WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
				if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
				{
					gWR.LoadWeaponSprites( tmp );
				}
#else
				ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
			}
			else
			{
				Error( "Expecting 'file', got %s\n", sub->GetName() );
			}
		}
	}
	manifest->deleteThis();
#endif
}