本文整理汇总了C++中KeyValues::deleteThis方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::deleteThis方法的具体用法?C++ KeyValues::deleteThis怎么用?C++ KeyValues::deleteThis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::deleteThis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveMapLayout
bool CMapLayout::SaveMapLayout( const char *filename )
{
KeyValues *pLayoutKeys = new KeyValues( "Layout" );
if ( m_pGenerationOptions )
{
pLayoutKeys->AddSubKey( m_pGenerationOptions->MakeCopy() );
}
KeyValues *pMiscKeys = new KeyValues( "mapmisc" );
pMiscKeys->SetInt( "PlayerStartX", m_iPlayerStartTileX );
pMiscKeys->SetInt( "PlayerStartY", m_iPlayerStartTileY );
pLayoutKeys->AddSubKey( pMiscKeys );
// save out each room
int iRooms = m_PlacedRooms.Count();
for (int i=0;i<iRooms;i++)
{
CRoom *pRoom = m_PlacedRooms[i];
if (!pRoom)
continue;
pLayoutKeys->AddSubKey( pRoom->GetKeyValuesCopy() );
}
// save out logical rooms
iRooms = m_LogicalRooms.Count();
for (int i=0;i<iRooms;i++)
{
KeyValues *pRoomKeys = new KeyValues( "logical_room" );
if ( m_LogicalRooms[i]->m_pLevelTheme )
{
pRoomKeys->SetString( "theme", m_LogicalRooms[i]->m_pLevelTheme->m_szName );
}
pRoomKeys->SetString( "template", m_LogicalRooms[i]->GetFullName() );
pLayoutKeys->AddSubKey( pRoomKeys );
}
for ( int i = 0; i < m_InstanceSpawns.Count(); ++ i )
{
KeyValues *pNewInstanceSpawn = new KeyValues( "instance_spawn" );
m_InstanceSpawns[i].SaveToKeyValues( pNewInstanceSpawn );
pLayoutKeys->AddSubKey( pNewInstanceSpawn );
}
for ( int i = 0; i < m_Encounters.Count(); ++ i )
{
KeyValues *pEncounterKeys = new KeyValues( "npc_encounter" );
m_Encounters[i]->SaveToKeyValues( pEncounterKeys );
pLayoutKeys->AddSubKey( pEncounterKeys );
}
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
for ( KeyValues *pKey = pLayoutKeys->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey() )
{
pKey->RecursiveSaveToFile( buf, 0 );
}
pLayoutKeys->deleteThis();
if ( !g_pFullFileSystem->WriteFile( filename, "GAME", buf ) )
{
Log_Warning( LOG_TilegenLayoutSystem, "Failed to SaveToFile %s\n", filename );
return false;
}
return true;
}
示例2: Update
//-----------------------------------------------------------------------------
// Purpose: Resets the list of players
//-----------------------------------------------------------------------------
void CSpectatorMenu::Update( void )
{
int itemID = 0;
IGameResources *gr = GameResources();
Reset();
if( m_iDuckKey < 0 )
{
m_iDuckKey = gameuifuncs->GetEngineKeyCodeForBind( "duck" );
}
if ( !gr )
return;
int iPlayerIndex;
for ( iPlayerIndex = 1 ; iPlayerIndex <= gpGlobals->maxClients; iPlayerIndex++ )
{
// does this slot in the array have a name?
if ( !gr->IsConnected( iPlayerIndex ) )
continue;
if ( gr->IsLocalPlayer( iPlayerIndex ) )
continue;
if ( !gr->IsAlive( iPlayerIndex ) )
continue;
wchar_t playerText[ 80 ], playerName[ 64 ], *team, teamText[ 64 ];
char localizeTeamName[64];
localize()->ConvertANSIToUnicode( UTIL_SafeName( gr->GetPlayerName(iPlayerIndex) ), playerName, sizeof( playerName ) );
const char * teamname = gr->GetTeamName( gr->GetTeam(iPlayerIndex) );
if ( teamname )
{
Q_snprintf( localizeTeamName, sizeof( localizeTeamName ), "#%s", teamname );
team=localize()->Find( localizeTeamName );
if ( !team )
{
localize()->ConvertANSIToUnicode( teamname , teamText, sizeof( teamText ) );
team = teamText;
}
localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem_Team" ), 2, playerName, team );
}
else
{
localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem" ), 1, playerName );
}
KeyValues *kv = new KeyValues("UserData", "player", gr->GetPlayerName( iPlayerIndex ) );
itemID = PlayerAddItem( itemID, playerText, kv ); // -1 means a new slot
kv->deleteThis();
}
// make sure the player combo box is up to date
int playernum = GetSpectatorTarget();
const char *selectedPlayerName = gr->GetPlayerName( playernum );
for ( iPlayerIndex=0; iPlayerIndex<m_pPlayerList->GetItemCount(); ++iPlayerIndex )
{
KeyValues *kv = m_pPlayerList->GetItemUserData( iPlayerIndex );
if ( kv && FStrEq( kv->GetString( "player" ), selectedPlayerName ) )
{
m_pPlayerList->ActivateItemByRow( iPlayerIndex );
m_pPlayerList->SetText( selectedPlayerName );
break;
}
}
}
示例3: ReadEncryptedKVFile
KeyValues* ReadEncryptedKVFile( IFileSystem *filesystem, const char *szFilenameWithoutExtension, const unsigned char *pICEKey, bool bForceReadEncryptedFile /*= false*/ )
{
Assert( strchr( szFilenameWithoutExtension, '.' ) == NULL );
char szFullName[512];
const char *pSearchPath = "MOD";
if ( pICEKey == NULL )
{
pSearchPath = "GAME";
}
// Open the weapon data file, and abort if we can't
KeyValues *pKV = new KeyValues( "WeaponDatafile" );
Q_snprintf(szFullName,sizeof(szFullName), "%s.txt", szFilenameWithoutExtension);
if ( bForceReadEncryptedFile || !pKV->LoadFromFile( filesystem, szFullName, pSearchPath ) ) // try to load the normal .txt file first
{
#ifndef _XBOX
if ( pICEKey )
{
Q_snprintf(szFullName,sizeof(szFullName), "%s.ctx", szFilenameWithoutExtension); // fall back to the .ctx file
FileHandle_t f = filesystem->Open( szFullName, "rb", pSearchPath );
if (!f)
{
pKV->deleteThis();
return NULL;
}
// load file into a null-terminated buffer
int fileSize = filesystem->Size(f);
char *buffer = (char*)MemAllocScratch(fileSize + 1);
Assert(buffer);
filesystem->Read(buffer, fileSize, f); // read into local buffer
buffer[fileSize] = 0; // null terminate file as EOF
filesystem->Close( f ); // close file after reading
UTIL_DecodeICE( (unsigned char*)buffer, fileSize, pICEKey );
bool retOK = pKV->LoadFromBuffer( szFullName, buffer, filesystem );
MemFreeScratch();
if ( !retOK )
{
pKV->deleteThis();
return NULL;
}
}
else
{
pKV->deleteThis();
return NULL;
}
#else
pKV->deleteThis();
return NULL;
#endif
}
return pKV;
}
示例4: PrecacheVars
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CMaterialSubRect::PrecacheVars( KeyValues * pVMTKeyValues, KeyValues * pPatchKeyValues, CUtlVector<FileNameHandle_t> *pIncludes )
{
// FIXME: Should call through to the parent material for all of this???
// We should get both parameters or neither
Assert( ( pVMTKeyValues == NULL ) ? ( pPatchKeyValues == NULL ) : ( pPatchKeyValues != NULL ) );
// Are we already precached?
if( IsPrecachedVars() )
return true;
// load data from the vmt file
bool bOk = false;
KeyValues *vmtKeyValues = NULL;
KeyValues *patchKeyValues = NULL;
if ( m_pVMTKeyValues )
{
// Use the procedural KeyValues
vmtKeyValues = m_pVMTKeyValues;
patchKeyValues = new KeyValues( "vmt_patches" );
// The caller should not be passing in KeyValues if we have procedural ones
Assert( ( pVMTKeyValues == NULL ) && ( pPatchKeyValues == NULL ) );
}
else if ( pVMTKeyValues )
{
// Use the passed-in (already-loaded) KeyValues
vmtKeyValues = pVMTKeyValues;
patchKeyValues = pPatchKeyValues;
}
else
{
// load data from the vmt file
vmtKeyValues = new KeyValues( "vmt" );
patchKeyValues = new KeyValues( "vmt_patches" );
if( !LoadVMTFile( *vmtKeyValues, *patchKeyValues, GetName(), UsesUNCFileName(), NULL ) )
{
Warning( "CMaterialSubRect::PrecacheVars: error loading vmt file for %s\n", GetName() );
goto precacheVarsDone;
}
}
// Get the "Subrect" material vars.
ParseMaterialVars( *vmtKeyValues );
// Setup the "Subrect" material vars.
SetupMaterialVars();
// Vars are precached.
m_fLocal |= MATERIALSUBRECT_VARS_IS_PRECACHED;
bOk = true;
precacheVarsDone:
// Clean up
if ( ( vmtKeyValues != m_pVMTKeyValues ) && ( vmtKeyValues != pVMTKeyValues ) )
{
vmtKeyValues->deleteThis();
}
if ( patchKeyValues != pPatchKeyValues )
{
patchKeyValues->deleteThis();
}
return bOk;
}
示例5: Update
//.........这里部分代码省略.........
KeyValues* pAnimation = pValues->FindKey("animation");
if (pAnimation)
pAnimation->SetString("sequence", VarArgs("%s_idle", WeaponIDToAlias(eFirst)));
KeyValues* pWeapon = pValues->FindKey("attached_model");
if (pWeapon)
pWeapon->SetString("modelname", pWeaponInfo->szWorldModel);
}
else
{
KeyValues* pAnimation = pValues->FindKey("animation");
if (pAnimation)
pAnimation->SetString("sequence", "idle");
KeyValues* pWeapon = pValues->FindKey("attached_model");
if (pWeapon)
pWeapon->SetString("modelname", "");
}
if (SDKGameRules()->IsTeamplay())
{
if (pPlayer->GetTeamNumber() == SDK_TEAM_BLUE)
pValues->SetInt("skin", 1);
else if (pPlayer->GetTeamNumber() == SDK_TEAM_RED)
pValues->SetInt("skin", 2);
else
pValues->SetInt("skin", 0);
}
else
pValues->SetInt("skin", 0);
pPlayerPreview->ParseModelInfo(pValues);
pValues->deleteThis();
}
else if (pPlayerPreview)
pPlayerPreview->SwapModel("");
for ( int i = 0; i < m_apWeaponIcons.Count(); i++)
{
if (m_apWeaponIcons[i].m_pWeaponName)
m_apWeaponIcons[i].m_pWeaponName->DeletePanel();
if (m_apWeaponIcons[i].m_pSlots)
m_apWeaponIcons[i].m_pSlots->DeletePanel();
if (m_apWeaponIcons[i].m_pImage)
m_apWeaponIcons[i].m_pImage->DeletePanel();
if (m_apWeaponIcons[i].m_pDelete)
m_apWeaponIcons[i].m_pDelete->DeletePanel();
}
m_apWeaponIcons.RemoveAll();
const char szWeaponPreviewTemplate[] =
" \"model\"\n"
" {\n"
" \"spotlight\" \"1\"\n"
" \"modelname\" \"models/weapons/beretta.mdl\"\n"
" \"origin_x\" \"30\"\n"
" \"origin_y\" \"3\"\n"
" \"origin_z\" \"-3\"\n"
" \"angles_y\" \"200\"\n"
" }";
示例6: UpdateMissionImage
//.........这里部分代码省略.........
DropDownMenu *menu = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpSelectMission", true ) );
#if 0
IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
if ( !pSource || !m_pSettings || !menu )
return;
const char *szGameType = m_pSettings->GetString( "game/mode", "campaign" );
if ( !Q_stricmp( szGameType, "campaign" ) )
{
const char *szCampaign = m_pSettings->GetString( "game/campaign", NULL );
if ( szCampaign )
{
KeyValues *pCampaignKeys = pSource->GetCampaignDetails( szCampaign );
if ( pCampaignKeys )
{
//imgLevelImage->SetImage( pCampaignKeys->GetString( "ChooseCampaignTexture" ) );
pMissionLabel->SetText( pCampaignKeys->GetString( "CampaignName" ) );
menu->SetCurrentSelection( pCampaignKeys->GetString( "CampaignName" ) );
}
}
if ( m_drpStartingMission )
{
m_drpStartingMission->SetVisible( true );
const char *szMission = m_pSettings->GetString( "game/mission", NULL );
if ( szMission )
{
KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
if ( pMissionKeys )
{
m_drpStartingMission->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
}
}
}
}
else if ( !Q_stricmp( szGameType, "single_mission" ) )
{
const char *szMission = m_pSettings->GetString( "game/mission", NULL );
if ( szMission )
{
KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
if ( pMissionKeys )
{
// TODO: Handle missions without an image
imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
pMissionLabel->SetText( pMissionKeys->GetString( "missiontitle" ) );
menu->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
}
}
if ( m_drpStartingMission )
{
m_drpStartingMission->SetVisible( false );
}
}
#else
const char *szGameType = m_pSettings->GetString( "game/mode", "sdk" );
if ( !Q_stricmp( szGameType, "sdk" ) )
{
const char *szMission = m_pSettings->GetString( "game/mission", NULL );
if ( szMission )
{
pMissionLabel->SetText( szMission );
menu->SetCurrentSelection( szMission );
}
if ( m_drpStartingMission )
{
m_drpStartingMission->SetVisible( false );
}
}
else if( !Q_stricmp( szGameType, "swarmkeeper" ) )
{
const char *szMission = m_pSettings->GetString( "game/mission", NULL );
if ( szMission )
{
char path[256];
Q_snprintf( path, 256, "maps/%s.res", szMission );
KeyValues *pData = new KeyValues("Data");
if( pData && pData->LoadFromFile( filesystem, path ) )
{
imgLevelImage->SetImage( pData->GetString( "image", "swarm/MissionPics/UnknownMissionPic" ) );
pMissionLabel->SetText( pData->GetString( "title" ) );
menu->SetCurrentSelection( pData->GetString( "title" ) );
}
else
{
imgLevelImage->SetImage( pData->GetString( "image", "swarm/MissionPics/UnknownMissionPic" ) );
pMissionLabel->SetText( szMission );
menu->SetCurrentSelection( szMission );
}
if( pData ) pData->deleteThis();
}
if ( m_drpStartingMission )
{
m_drpStartingMission->SetVisible( false );
}
}
#endif // 0
}
示例7: KeyValues
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHL2MPClientScoreBoardDialog::UpdatePlayerInfo()
{
m_iSectionId = 0; // 0'th row is a header
int selectedRow = -1;
int i;
CBasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pPlayer || !g_PR )
return;
// walk all the players and make sure they're in the scoreboard
for ( i = 1; i <= gpGlobals->maxClients; i++ )
{
bool shouldShow = g_PR->IsConnected( i );
if ( shouldShow )
{
// add the player to the list
KeyValues *playerData = new KeyValues("data");
GetPlayerScoreInfo( i, playerData );
int itemID = FindItemIDForPlayerIndex( i );
int sectionID = GetSectionFromTeamNumber( g_PR->GetTeam( i ) );
if (itemID == -1)
{
// add a new row
itemID = m_pPlayerList->AddItem( sectionID, playerData );
}
else
{
// modify the current row
m_pPlayerList->ModifyItem( itemID, sectionID, playerData );
}
if ( i == pPlayer->entindex() )
{
selectedRow = itemID; // this is the local player, hilight this row
}
// set the row color based on the players team
m_pPlayerList->SetItemFgColor( itemID, g_PR->GetTeamColor( g_PR->GetTeam( i ) ) );
playerData->deleteThis();
}
else
{
// remove the player
int itemID = FindItemIDForPlayerIndex( i );
if (itemID != -1)
{
m_pPlayerList->RemoveItem(itemID);
}
}
}
if ( selectedRow != -1 )
{
m_pPlayerList->SetSelectedItem(selectedRow);
}
}
示例8: RunFrame
//-----------------------------------------------------------------------------
// Purpose: paints all the vgui elements
//-----------------------------------------------------------------------------
void CGameUI::RunFrame()
{
if ( IsX360() && m_bOpenProgressOnStart )
{
StartProgressBar();
m_bOpenProgressOnStart = false;
}
int wide, tall;
#if defined( TOOLFRAMEWORK_VGUI_REFACTOR )
// resize the background panel to the screen size
vgui::VPANEL clientDllPanel = enginevguifuncs->GetPanel( PANEL_ROOT );
int x, y;
vgui::ipanel()->GetPos( clientDllPanel, x, y );
vgui::ipanel()->GetSize( clientDllPanel, wide, tall );
staticPanel->SetBounds( x, y, wide,tall );
#else
vgui::surface()->GetScreenSize(wide, tall);
GetUiBaseModPanelClass().SetSize(wide, tall);
#endif
// Run frames
g_VModuleLoader.RunFrame();
GetUiBaseModPanelClass().RunFrame();
// Play the start-up music the first time we run frame
if ( IsPC() && m_iPlayGameStartupSound > 0 )
{
m_iPlayGameStartupSound--;
if ( !m_iPlayGameStartupSound )
{
PlayGameStartupSound();
}
}
if ( IsPC() && m_bTryingToLoadFriends && m_iFriendsLoadPauseFrames-- < 1 && g_hMutex && g_hWaitMutex )
{
// try and load Steam platform files
unsigned int waitResult = Sys_WaitForSingleObject(g_hMutex, 0);
if (waitResult == SYS_WAIT_OBJECT_0 || waitResult == SYS_WAIT_ABANDONED)
{
// we got the mutex, so load Friends/Serverbrowser
// clear the loading flag
m_bTryingToLoadFriends = false;
g_VModuleLoader.LoadPlatformModules(&m_GameFactory, 1, false);
// release the wait mutex
Sys_ReleaseMutex(g_hWaitMutex);
// notify the game of our game name
const char *fullGamePath = engine->GetGameDirectory();
const char *pathSep = strrchr( fullGamePath, '/' );
if ( !pathSep )
{
pathSep = strrchr( fullGamePath, '\\' );
}
if ( pathSep )
{
KeyValues *pKV = new KeyValues("ActiveGameName" );
pKV->SetString( "name", pathSep + 1 );
pKV->SetInt( "appid", engine->GetAppID() );
KeyValues *modinfo = new KeyValues("ModInfo");
if ( modinfo->LoadFromFile( g_pFullFileSystem, "gameinfo.txt" ) )
{
pKV->SetString( "game", modinfo->GetString( "game", "" ) );
}
modinfo->deleteThis();
g_VModuleLoader.PostMessageToAllModules( pKV );
}
// notify the ui of a game connect if we're already in a game
if (m_iGameIP)
{
SendConnectedToGameMessage();
}
}
}
}
示例9: ParseActionDescriptions
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void COptionsSubKeyboard::ParseActionDescriptions( void )
{
char szBinding[256];
char szDescription[256];
KeyValues *item;
// Load the default keys list
CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
if ( !g_pFullFileSystem->ReadFile( "scripts/kb_act.lst", NULL, buf ) )
return;
const char *data = (const char*)buf.Base();
int sectionIndex = 0;
char token[512];
while ( 1 )
{
data = UTIL_Parse( data, token, sizeof(token) );
// Done.
if ( strlen( token ) <= 0 )
break;
Q_strncpy( szBinding, token, sizeof( szBinding ) );
data = UTIL_Parse( data, token, sizeof(token) );
if ( strlen(token) <= 0 )
{
break;
}
Q_strncpy(szDescription, token, sizeof( szDescription ) );
// Skip '======' rows
if ( szDescription[ 0 ] != '=' )
{
// Flag as special header row if binding is "blank"
if (!stricmp(szBinding, "blank"))
{
// add header item
int nColumn1 = 286;
int nColumn2 = 128;
if ( IsProportional() )
{
nColumn1 = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), nColumn1 );
nColumn2 = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), nColumn2 );
}
m_pKeyBindList->AddSection(++sectionIndex, szDescription);
m_pKeyBindList->AddColumnToSection(sectionIndex, "Action", szDescription, SectionedListPanel::COLUMN_BRIGHT, nColumn1 );
m_pKeyBindList->AddColumnToSection(sectionIndex, "Key", "#GameUI_KeyButton", SectionedListPanel::COLUMN_BRIGHT, nColumn2 );
}
else
{
// Create a new: blank item
item = new KeyValues( "Item" );
// fill in data
item->SetString("Action", szDescription);
item->SetString("Binding", szBinding);
item->SetString("Key", "");
// Add to list
m_pKeyBindList->AddItem(sectionIndex, item);
item->deleteThis();
}
}
}
}
示例10: LoadDecalsFromScript
//-----------------------------------------------------------------------------
// Purpose:
// Input : *filename -
//-----------------------------------------------------------------------------
void CDecalEmitterSystem::LoadDecalsFromScript( char const *filename )
{
KeyValues *kv = new KeyValues( filename );
Assert( kv );
if ( kv )
{
KeyValues *translation = NULL;
#ifndef _XBOX
if ( kv->LoadFromFile( filesystem, filename ) )
#else
if ( kv->LoadFromFile( filesystem, filename, "GAME" ) )
#endif
{
KeyValues *p = kv;
while ( p )
{
if ( p->GetFirstSubKey() )
{
char const *keyname = p->GetName();
if ( !Q_stricmp( keyname, TRANSLATION_DATA_SECTION ) )
{
translation = p;
}
else
{
DecalEntry entry;
for ( KeyValues *sub = p->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
{
MEM_ALLOC_CREDIT();
DecalListEntry decal;
decal.precache_index = -1;
decal.name = m_DecalFileNames.AddString( sub->GetName() );
decal.weight = sub->GetFloat();
// Add to global list
int idx = m_AllDecals.AddToTail( decal );
// Add index only to local list
entry.indices.AddToTail( idx );
}
// Add entry to main dictionary
m_Decals.Insert( keyname, entry );
}
}
p = p->GetNextKey();
}
}
else
{
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Unable to load '%s'\n", filename );
}
if ( !translation )
{
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Script '%s' missing section '%s'\n",
filename,
TRANSLATION_DATA_SECTION );
}
else
{
// Now parse game material to entry translation table
for ( KeyValues *sub = translation->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
{
// Don't add NULL string to list
if ( !Q_stricmp( sub->GetString(), "" ) )
continue;
int idx = m_Decals.Find( sub->GetString() );
if ( idx != m_Decals.InvalidIndex() )
{
m_GameMaterialTranslation.Insert( sub->GetName(), idx );
}
else
{
Msg( "CDecalEmitterSystem::LoadDecalsFromScript: Translation for game material type '%s' references unknown decal '%s'\n",
sub->GetName(), sub->GetString() );
}
}
}
kv->deleteThis();
}
}
示例11: UpdatePlayerInfo
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CClientScoreBoardDialog::UpdatePlayerInfo()
{
m_iSectionId = 0; // 0'th row is a header
int selectedRow = -1;
// walk all the players and make sure they're in the scoreboard
for ( int i = 1; i <= gpGlobals->maxClients; ++i )
{
IGameResources *gr = GameResources();
if ( gr && gr->IsConnected( i ) )
{
// add the player to the list
KeyValues *playerData = new KeyValues("data");
GetPlayerScoreInfo( i, playerData );
UpdatePlayerAvatar( i, playerData );
const char *oldName = playerData->GetString("name","");
int bufsize = strlen(oldName) * 2 + 1;
char *newName = (char *)_alloca( bufsize );
UTIL_MakeSafeName( oldName, newName, bufsize );
playerData->SetString("name", newName);
int itemID = FindItemIDForPlayerIndex( i );
int sectionID = gr->GetTeam( i );
if ( gr->IsLocalPlayer( i ) )
{
selectedRow = itemID;
}
if (itemID == -1)
{
// add a new row
itemID = m_pPlayerList->AddItem( sectionID, playerData );
}
else
{
// modify the current row
m_pPlayerList->ModifyItem( itemID, sectionID, playerData );
}
// set the row color based on the players team
m_pPlayerList->SetItemFgColor( itemID, gr->GetTeamColor( sectionID ) );
playerData->deleteThis();
}
else
{
// remove the player
int itemID = FindItemIDForPlayerIndex( i );
if (itemID != -1)
{
m_pPlayerList->RemoveItem(itemID);
}
}
}
if ( selectedRow != -1 )
{
m_pPlayerList->SetSelectedItem(selectedRow);
}
}
示例12: UpdateLightNew
//.........这里部分代码省略.........
if ( pPlayer )
{
float flBatteryPower = ( pPlayer->m_HL2Local.m_flFlashBattery >= 0.0f ) ? ( pPlayer->m_HL2Local.m_flFlashBattery ) : pPlayer->m_HL2Local.m_flSuitPower;
if ( flBatteryPower <= 10.0f )
{
float flScale;
if ( flBatteryPower >= 0.0f )
{
flScale = ( flBatteryPower <= 4.5f ) ? SimpleSplineRemapVal( flBatteryPower, 4.5f, 0.0f, 1.0f, 0.0f ) : 1.0f;
}
else
{
flScale = SimpleSplineRemapVal( flBatteryPower, 10.0f, 4.8f, 1.0f, 0.0f );
}
flScale = clamp( flScale, 0.0f, 1.0f );
if ( flScale < 0.35f )
{
float flFlicker = cosf( gpGlobals->curtime * 6.0f ) * sinf( gpGlobals->curtime * 15.0f );
if ( flFlicker > 0.25f && flFlicker < 0.75f )
{
// On
state.m_fLinearAtten = r_flashlightlinear.GetFloat() * flScale;
}
else
{
// Off
state.m_fLinearAtten = 0.0f;
}
}
else
{
float flNoise = cosf( gpGlobals->curtime * 7.0f ) * sinf( gpGlobals->curtime * 25.0f );
state.m_fLinearAtten = r_flashlightlinear.GetFloat() * flScale + 1.5f * flNoise;
}
state.m_fHorizontalFOVDegrees = r_flashlightfov.GetFloat() - ( 16.0f * (1.0f-flScale) );
state.m_fVerticalFOVDegrees = r_flashlightfov.GetFloat() - ( 16.0f * (1.0f-flScale) );
bFlicker = true;
}
}
#endif // HL2_EPISODIC
if ( bFlicker == false )
{
state.m_fLinearAtten = r_flashlightlinear.GetFloat();
state.m_fHorizontalFOVDegrees = r_flashlightfov.GetFloat();
state.m_fVerticalFOVDegrees = r_flashlightfov.GetFloat();
}
state.m_fConstantAtten = r_flashlightconstant.GetFloat();
state.m_Color[0] = 1.0f;
state.m_Color[1] = 1.0f;
state.m_Color[2] = 1.0f;
state.m_Color[3] = r_flashlightambient.GetFloat();
state.m_NearZ = r_flashlightnear.GetFloat() + m_flDistMod; // Push near plane out so that we don't clip the world when the flashlight pulls back
state.m_FarZ = r_flashlightfar.GetFloat();
state.m_bEnableShadows = r_flashlightdepthtexture.GetBool();
state.m_flShadowMapResolution = r_flashlightdepthres.GetInt();
state.m_pSpotlightTexture = m_FlashlightTexture;
state.m_nSpotlightTextureFrame = 0;
state.m_flShadowAtten = r_flashlightshadowatten.GetFloat();
state.m_flShadowSlopeScaleDepthBias = mat_slopescaledepthbias_shadowmap.GetFloat();
state.m_flShadowDepthBias = mat_depthbias_shadowmap.GetFloat();
if( m_FlashlightHandle == CLIENTSHADOW_INVALID_HANDLE )
{
m_FlashlightHandle = g_pClientShadowMgr->CreateFlashlight( state );
}
else
{
if( !r_flashlightlockposition.GetBool() )
{
g_pClientShadowMgr->UpdateFlashlightState( m_FlashlightHandle, state );
}
}
g_pClientShadowMgr->UpdateProjectedTexture( m_FlashlightHandle, true );
// Kill the old flashlight method if we have one.
LightOffOld();
#ifndef NO_TOOLFRAMEWORK
if ( clienttools->IsInRecordingMode() )
{
KeyValues *msg = new KeyValues( "FlashlightState" );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetInt( "entindex", m_nEntIndex );
msg->SetInt( "flashlightHandle", m_FlashlightHandle );
msg->SetPtr( "flashlightState", &state );
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
#endif
}
示例13: Init
bool CEngineSprite::Init( const char *pName )
{
m_VideoMaterial = NULL;
for ( int i = 0; i < kRenderModeCount; ++i )
{
m_material[ i ] = NULL;
}
m_width = m_height = m_numFrames = 1;
Assert( g_pVideo != NULL );
if ( g_pVideo != NULL && g_pVideo->LocateVideoSystemForPlayingFile( pName ) != VideoSystem::NONE )
{
m_VideoMaterial = g_pVideo->CreateVideoMaterial( pName, pName, "GAME", VideoPlaybackFlags::DEFAULT_MATERIAL_OPTIONS, VideoSystem::DETERMINE_FROM_FILE_EXTENSION, false );
if ( m_VideoMaterial == NULL )
return false;
IMaterial *pMaterial = m_VideoMaterial->GetMaterial();
m_VideoMaterial->GetVideoImageSize( &m_width, &m_height );
m_numFrames = m_VideoMaterial->GetFrameCount();
for ( int i = 0; i < kRenderModeCount; ++i )
{
m_material[i] = pMaterial;
pMaterial->IncrementReferenceCount();
}
}
else
{
char pTemp[MAX_PATH];
char pMaterialName[MAX_PATH];
char pMaterialPath[MAX_PATH];
Q_StripExtension( pName, pTemp, sizeof(pTemp) );
Q_strlower( pTemp );
Q_FixSlashes( pTemp, '/' );
// Check to see if this is a UNC-specified material name
bool bIsUNC = pTemp[0] == '/' && pTemp[1] == '/' && pTemp[2] != '/';
if ( !bIsUNC )
{
Q_strncpy( pMaterialName, "materials/", sizeof(pMaterialName) );
Q_strncat( pMaterialName, pTemp, sizeof(pMaterialName), COPY_ALL_CHARACTERS );
}
else
{
Q_strncpy( pMaterialName, pTemp, sizeof(pMaterialName) );
}
Q_strncpy( pMaterialPath, pMaterialName, sizeof(pMaterialPath) );
Q_SetExtension( pMaterialPath, ".vmt", sizeof(pMaterialPath) );
KeyValues *kv = new KeyValues( "vmt" );
if ( !kv->LoadFromFile( g_pFullFileSystem, pMaterialPath, "GAME" ) )
{
Warning( "Unable to load sprite material %s!\n", pMaterialPath );
return false;
}
for ( int i = 0; i < kRenderModeCount; ++i )
{
if ( i == kRenderNone || i == kRenderEnvironmental )
{
m_material[i] = NULL;
continue;
}
Q_snprintf( pMaterialPath, sizeof(pMaterialPath), "%s_rendermode_%d", pMaterialName, i );
KeyValues *pMaterialKV = kv->MakeCopy();
pMaterialKV->SetInt( "$spriteRenderMode", i );
m_material[i] = g_pMaterialSystem->FindProceduralMaterial( pMaterialPath, TEXTURE_GROUP_CLIENT_EFFECTS, pMaterialKV );
m_material[ i ]->IncrementReferenceCount();
}
kv->deleteThis();
m_width = m_material[0]->GetMappingWidth();
m_height = m_material[0]->GetMappingHeight();
m_numFrames = m_material[0]->GetNumAnimationFrames();
}
for ( int i = 0; i < kRenderModeCount; ++i )
{
if ( i == kRenderNone || i == kRenderEnvironmental )
continue;
if ( !m_material[i] )
return false;
}
IMaterialVar *orientationVar = m_material[0]->FindVarFast( "$spriteorientation", &spriteOrientationCache );
m_orientation = orientationVar ? orientationVar->GetIntValue() : C_SpriteRenderer::SPR_VP_PARALLEL_UPRIGHT;
IMaterialVar *originVar = m_material[0]->FindVarFast( "$spriteorigin", &spriteOriginCache );
Vector origin, originVarValue;
if( !originVar || ( originVar->GetType() != MATERIAL_VAR_TYPE_VECTOR ) )
{
origin[0] = -m_width * 0.5f;
origin[1] = m_height * 0.5f;
}
else
//.........这里部分代码省略.........
示例14: PopulateList
//.........这里部分代码省略.........
map = map->baseMap;
}
pPanel = pPanel->GetParent();
if ( !pPanel )
break;
}
CUtlRBTree< KeyValues *, int > sorted( 0, 0, BindingLessFunc );
// add header item
int c = maps.Count();
for ( i = 0; i < c; ++i )
{
PanelKeyBindingMap *m = maps[ i ].m_pMap;
Panel *pMapPanel = maps[i].m_pPanel;
Assert( m );
int bindings = m->boundkeys.Count();
for ( j = 0; j < bindings; ++j )
{
BoundKey_t *kbMap = &m->boundkeys[ j ];
Assert( kbMap );
// Create a new: blank item
KeyValues *item = new KeyValues( "Item" );
// Fill in data
char loc[ 128 ];
Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname );
char ansi[ 256 ];
AnsiText( loc, ansi, sizeof( ansi ) );
item->SetString( "Action", ansi );
item->SetWString( "Binding", Panel::KeyCodeModifiersToDisplayString( (KeyCode)kbMap->keycode, kbMap->modifiers ) );
// Find the binding
KeyBindingMap_t *bindingMap = pMapPanel->LookupBinding( kbMap->bindingname );
if ( bindingMap &&
bindingMap->helpstring )
{
AnsiText( bindingMap->helpstring, ansi, sizeof( ansi ) );
item->SetString( "Description", ansi );
}
item->SetPtr( "Item", kbMap );
sorted.Insert( item );
}
// Now try and find any "unbound" keys...
int mappings = m->entries.Count();
for ( j = 0; j < mappings; ++j )
{
KeyBindingMap_t *kbMap = &m->entries[ j ];
// See if it's bound
CUtlVector< BoundKey_t * > list;
pMapPanel->LookupBoundKeys( kbMap->bindingname, list );
if ( list.Count() > 0 )
continue;
// Not bound, add a placeholder entry
// Create a new: blank item
KeyValues *item = new KeyValues( "Item" );
// fill in data
char loc[ 128 ];
Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname );
char ansi[ 256 ];
AnsiText( loc, ansi, sizeof( ansi ) );
item->SetString( "Action", ansi );
item->SetWString( "Binding", L"" );
if ( kbMap->helpstring )
{
AnsiText( kbMap->helpstring, ansi, sizeof( ansi ) );
item->SetString( "Description", ansi );
}
item->SetPtr( "Unbound", kbMap );
sorted.Insert( item );
}
}
for ( j = sorted.FirstInorder() ; j != sorted.InvalidIndex(); j = sorted.NextInorder( j ) )
{
KeyValues *item = sorted[ j ];
// Add to list
m_pList->AddItem( item, 0, false, false );
item->deleteThis();
}
sorted.RemoveAll();
}
示例15: Init
//-----------------------------------------------------------------------------
// Purpose: This is called every time the DLL is loaded
//-----------------------------------------------------------------------------
void CHud::Init( void )
{
HOOK_HUD_MESSAGE( gHUD, ResetHUD );
#ifdef CSTRIKE_DLL
HOOK_HUD_MESSAGE( gHUD, SendAudio );
#endif
InitFonts();
// Create all the Hud elements
CHudElementHelper::CreateAllElements();
gLCD.Init();
// Initialize all created elements
for ( int i = 0; i < m_HudList.Size(); i++ )
{
m_HudList[i]->Init();
}
m_bHudTexturesLoaded = false;
KeyValues *kv = new KeyValues( "layout" );
if ( kv )
{
if ( kv->LoadFromFile( filesystem, "scripts/HudLayout.res" ) )
{
int numelements = m_HudList.Size();
for ( int i = 0; i < numelements; i++ )
{
CHudElement *element = m_HudList[i];
vgui::Panel *pPanel = dynamic_cast<vgui::Panel*>(element);
if ( !pPanel )
{
Msg( "Non-vgui hud element %s\n", m_HudList[i]->GetName() );
continue;
}
KeyValues *key = kv->FindKey( pPanel->GetName(), false );
if ( !key )
{
Msg( "Hud element '%s' doesn't have an entry '%s' in scripts/HudLayout.res\n", m_HudList[i]->GetName(), pPanel->GetName() );
}
// Note: When a panel is parented to the module root, it's "parent" is returned as NULL.
if ( !element->IsParentedToClientDLLRootPanel() &&
!pPanel->GetParent() )
{
DevMsg( "Hud element '%s'/'%s' doesn't have a parent\n", m_HudList[i]->GetName(), pPanel->GetName() );
}
}
}
kv->deleteThis();
}
if ( m_bHudTexturesLoaded )
return;
m_bHudTexturesLoaded = true;
CUtlDict< CHudTexture *, int > textureList;
// check to see if we have sprites for this res; if not, step down
LoadHudTextures( textureList, "scripts/hud_textures", NULL );
LoadHudTextures( textureList, "scripts/mod_textures", NULL );
int c = textureList.Count();
for ( int index = 0; index < c; index++ )
{
CHudTexture* tex = textureList[ index ];
AddSearchableHudIconToList( *tex );
}
FreeHudTextureList( textureList );
}