本文整理汇总了C++中KeyValues::FindKey方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::FindKey方法的具体用法?C++ KeyValues::FindKey怎么用?C++ KeyValues::FindKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::FindKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParsePropData
//-----------------------------------------------------------------------------
// Purpose: Parse this prop's data from the model, if it has a keyvalues section.
// Returns true only if this prop is using a model that has a prop_data section that's invalid.
//-----------------------------------------------------------------------------
int C_PhysPropClientside::ParsePropData( void )
{
KeyValues *modelKeyValues = new KeyValues("");
if ( !modelKeyValues->LoadFromBuffer( modelinfo->GetModelName( GetModel() ), modelinfo->GetModelKeyValueText( GetModel() ) ) )
{
modelKeyValues->deleteThis();
return PARSE_FAILED_NO_DATA;
}
// Do we have a props section?
KeyValues *pkvPropData = modelKeyValues->FindKey("prop_data");
if ( !pkvPropData )
{
modelKeyValues->deleteThis();
return PARSE_FAILED_NO_DATA;
}
int iResult = g_PropDataSystem.ParsePropFromKV( this, pkvPropData, modelKeyValues );
modelKeyValues->deleteThis();
return iResult;
}
示例2: HintEventFn_BuildObject
void HintEventFn_BuildObject( CHintData *pData, C_HintEvent_Base *pEvent )
{
if ( pEvent->GetType() == HINTEVENT_OBJECT_BUILT_BY_LOCAL_PLAYER )
{
C_BaseObject *pObj = ((C_HintEvent_ObjectBuiltByLocalPlayer*)pEvent)->m_pObject;
if ( pObj->GetType() == pData->m_ObjectType )
{
// Ok, they just built the object that any hints of this type are referring to, so disable
// all further hints of this type.
KeyValues *pkvStats = GetHintDisplayStats();
if ( pkvStats )
{
KeyValues *pkvStatSection = pkvStats->FindKey( pData->name, true );
if ( pkvStatSection )
{
pkvStatSection->SetString( "times_shown", VarArgs( "%i", 100 ) );
}
}
}
}
}
示例3: GetCampaignSaveIntroMap
const char* CASW_Mission_Chooser_Source_Local::GetCampaignSaveIntroMap(const char *szSaveName)
{
// check the save file exists
char stripped[MAX_PATH];
V_StripExtension( szSaveName, stripped, MAX_PATH );
char tempfile[MAX_PATH];
Q_snprintf( tempfile, sizeof( tempfile ), "save/%s.campaignsave", stripped );
if (!g_pFullFileSystem->FileExists(tempfile))
return NULL;
KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
KeyValues::AutoDelete saveKeyValuesAutoDelete( pSaveKeyValues );
const char* pszCampaign = NULL;
if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile))
pszCampaign = pSaveKeyValues->GetString("CampaignName");
if (!pszCampaign)
return NULL;
// now read in the campaign txt and find the intro map name
KeyValues *pCampaignKeyValues = GetCampaignDetails( pszCampaign );
if (pCampaignKeyValues)
{
KeyValues *pMission = pCampaignKeyValues->FindKey("MISSION");
Assert(pMission);
if (pMission)
{
pMission = pMission->GetNextKey();
Assert(pMission && !Q_stricmp(pMission->GetName(), "MISSION"));
if (pMission && !Q_stricmp(pMission->GetName(), "MISSION"))
{
Assert(pMission->GetString("MapName", NULL));
return pMission->GetString("MapName", NULL);
}
}
}
return NULL;
}
示例4: CreateVPhysics
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
bool CNPC_Furniture::CreateVPhysics( void )
{
#ifndef HL2_DLL
return false;
#endif
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 )
{
// Create our bone manager if we don't have one already
if ( !m_pBoneFollowerManager )
{
m_pBoneFollowerManager = new CBoneFollowerManager();
}
// 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_pBoneFollowerManager->AddBoneFollower( this, pBoneName );
pBone = pBone->GetNextKey();
}
modelKeyValues->deleteThis();
return true;
}
modelKeyValues->deleteThis();
}
return true;
}
示例5: OutputKeyValuesVersion
//-----------------------------------------------------------------------------
// Purpose: debug helper, spits out a human readable keyvalues version of the various configs
//-----------------------------------------------------------------------------
void OutputKeyValuesVersion( CVCProjConvert & proj )
{
KeyValues *kv = new KeyValues( "project" );
for ( int projIndex = 0; projIndex < proj.GetNumConfigurations(); projIndex++ )
{
CVCProjConvert::CConfiguration & config = proj.GetConfiguration(projIndex);
KeyValues *configKv = kv->FindKey( config.GetName().String(), true );
int fileCount = 0;
for( int fileIndex = 0; fileIndex < config.GetNumFileNames(); fileIndex++ )
{
if ( config.GetFileType(fileIndex) == CVCProjConvert::CConfiguration::FILE_SOURCE )
{
char num[20];
Q_snprintf( num, sizeof(num), "%i", fileCount );
fileCount++;
configKv->SetString( num, config.GetFileName(fileIndex) );
}
}
}
kv->SaveToFile( g_pFileSystem, "files.vdf" );
kv->deleteThis();
}
示例6: IsStaticProp
isstaticprop_ret IsStaticProp( studiohdr_t* pHdr )
{
if (!(pHdr->flags & STUDIOHDR_FLAGS_STATIC_PROP))
return RET_FAIL_NOT_MARKED_STATIC_PROP;
// If it's got a propdata section in the model's keyvalues, it's not allowed to be a prop_static
KeyValues *modelKeyValues = new KeyValues(pHdr->pszName());
if ( StudioKeyValues( pHdr, modelKeyValues ) )
{
KeyValues *sub = modelKeyValues->FindKey("prop_data");
if ( sub )
{
if ( !(sub->GetInt( "allowstatic", 0 )) )
{
modelKeyValues->deleteThis();
return RET_FAIL_DYNAMIC;
}
}
}
modelKeyValues->deleteThis();
return RET_VALID;
}
示例7: LoadMountsFromKeyValues
bool C_MountManager::LoadMountsFromKeyValues(std::string filename)
{
unsigned int mountCount = 0;
KeyValues* pKv = new KeyValues("mounts");
if (pKv->LoadFromFile(g_pFullFileSystem, filename.c_str(), "MOD"))
{
for (KeyValues *pMountKv = pKv->GetFirstSubKey(); pMountKv; pMountKv = pMountKv->GetNextKey())
{
C_Mount* pMount = new C_Mount();
std::string id = pMountKv->GetString("id");
std::string title = pMountKv->GetString("title");
std::string base = pMountKv->GetString("base");
std::vector<std::string> paths;
for (KeyValues *sub = pMountKv->FindKey("paths", true)->GetFirstSubKey(); sub; sub = sub->GetNextKey())
paths.push_back(sub->GetString());
pMount->Init(id, title, base, paths);
// if (pKv->GetBool("active"))
// {
if (pMount->Activate())
mountCount++;
m_mounts[id] = pMount;
// }
}
}
pKv->deleteThis();
std::string num = VarArgs("%u", mountCount);
C_AwesomiumBrowserInstance* pHudBrowserInstance = g_pAnarchyManager->GetAwesomiumBrowserManager()->FindAwesomiumBrowserInstance("hud");
pHudBrowserInstance->AddHudLoadingMessage("progress", "", "Mounting Source Engine Games", "mounts", "0", num, num);
return false;
}
示例8: smn_KvDeleteKey
static cell_t smn_KvDeleteKey(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
KeyValueStack *pStk;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
if (pStk->pCurRoot.size() < 2)
{
return 0;
}
char *keyName;
pContext->LocalToString(params[2], &keyName);
KeyValues *pRoot = pStk->pCurRoot.front();
KeyValues *pValues = pRoot->FindKey(keyName);
if (!pValues)
{
return 0;
}
pRoot->RemoveSubKey(pValues);
pValues->deleteThis();
return 1;
}
示例9: RecursiveLoadGameMenu
//-----------------------------------------------------------------------------
// Purpose: sets up the game menu from the keyvalues
// the game menu is hierarchial, so this is recursive
//-----------------------------------------------------------------------------
vgui::Menu *CGameMenuButton::RecursiveLoadGameMenu(KeyValues *datafile)
{
Menu *menu = new vgui::Menu(this, datafile->GetName());
// loop through all the data adding items to the menu
for (KeyValues *dat = datafile->GetFirstSubKey(); dat != NULL; dat = dat->GetNextKey())
{
const char *label = dat->GetString("label", "<unknown>");
const char *cmd = dat->GetString("command", NULL);
const char *name = dat->GetString("name", label);
KeyValues *subkeys = dat->FindKey("SubMenu", false);
Menu *submenu = NULL;
if (subkeys)
{
// it's a hierarchial menu
submenu = RecursiveLoadGameMenu(subkeys);
}
menu->AddCascadingMenuItem(name, label, cmd, this, submenu);
}
return menu;
}
示例10: OnItemSelected
//=============================================================================
void CustomCampaigns::OnItemSelected( const char* panelName )
{
CustomCampaignListItem *pSelectedItem = static_cast< CustomCampaignListItem * >( m_GplCustomCampaigns->GetSelectedPanelItem() );
if ( !pSelectedItem )
return;
KeyValues *pAllMissions = g_pMatchExtSwarm->GetAllMissions();
if ( !pAllMissions )
return;
char const *szGameMode = m_pDataSettings->GetString( "game/mode", "campaign" );
KeyValues *pMission = pAllMissions->FindKey( pSelectedItem->GetCampaignContext() );
KeyValues *pFirstChapter = pAllMissions->FindKey( CFmtStr( "%s/modes/%s/1", pSelectedItem->GetCampaignContext(), szGameMode ) );
if ( !pFirstChapter || !pMission )
return;
const char *missionImage = pFirstChapter->GetString( "image" );
const char *missionDesc = pMission->GetString( "description" );
const char *campaignAuthor = pMission->GetString( "author" );
const char *campaignWebsite = pMission->GetString( "website" );
wchar_t finalString[MAX_PATH] = L"";
wchar_t convertedString[MAX_PATH] = L"";
if( m_lblAuthor )
{
if ( campaignAuthor )
{
const wchar_t * authorFormat = g_pVGuiLocalize->Find( "#L4D360UI_CustomCampaign_Author" );
g_pVGuiLocalize->ConvertANSIToUnicode( campaignAuthor, convertedString, sizeof( convertedString ) );
if ( authorFormat )
{
g_pVGuiLocalize->ConstructString( finalString, sizeof( finalString ), authorFormat, 1, convertedString );
m_lblAuthor->SetText( finalString );
}
m_lblAuthor->SetVisible( true );
}
else
{
m_lblAuthor->SetVisible( false );
}
}
if( m_lblWebsite )
{
if ( campaignWebsite )
{
const wchar_t * websiteFormat = g_pVGuiLocalize->Find( "#L4D360UI_CustomCampaign_Website" );
g_pVGuiLocalize->ConvertANSIToUnicode( campaignWebsite, convertedString, sizeof( convertedString ) );
if ( websiteFormat )
{
g_pVGuiLocalize->ConstructString( finalString, sizeof( finalString ), websiteFormat, 1, convertedString );
m_lblWebsite->SetText( finalString );
}
m_lblWebsite->SetVisible( true );
}
else
{
m_lblWebsite->SetVisible( false );
}
}
if( m_lblDescription )
{
if ( missionDesc )
{
m_lblDescription->SetText( missionDesc );
m_lblDescription->SetVisible( true );
}
else
{
m_lblDescription->SetVisible( false );
}
}
if ( m_imgLevelImage )
{
m_imgLevelImage->SetVisible( true );
if( missionImage )
{
m_imgLevelImage->SetImage( missionImage );
}
else
{
m_imgLevelImage->SetImage( "swarm/MissionPics/addonMissionPic" );
}
}
}
示例11: FX_MuzzleEffectAttached
//.........这里部分代码省略.........
{
pParticle->m_uchColor[0] = pFlashColor[0];
pParticle->m_uchColor[1] = pFlashColor[1];
pParticle->m_uchColor[2] = pFlashColor[2];
}
pParticle->m_uchStartAlpha = 255;
pParticle->m_uchEndAlpha = 128;
pParticle->m_uchStartSize = (random->RandomFloat( 6.0f, 9.0f ) * (12-(i))/9) * flScale;
pParticle->m_uchEndSize = pParticle->m_uchStartSize;
pParticle->m_flRoll = random->RandomInt( 0, 360 );
pParticle->m_flRollDelta = 0.0f;
}
if ( !ToolsEnabled() )
return;
if ( !clienttools->IsInRecordingMode() )
return;
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( hEntity );
if ( pEnt )
{
pEnt->RecordToolMessage();
}
// NOTE: Particle system destruction message will be sent by the particle effect itself.
int nId = pSimple->AllocateToolParticleEffectId();
KeyValues *msg = new KeyValues( "OldParticleSystem_Create" );
msg->SetString( "name", "FX_MuzzleEffectAttached" );
msg->SetInt( "id", nId );
msg->SetFloat( "time", gpGlobals->curtime );
KeyValues *pEmitter = msg->FindKey( "DmeSpriteEmitter", true );
pEmitter->SetInt( "count", 9 );
pEmitter->SetFloat( "duration", 0 );
pEmitter->SetString( "material", "effects/muzzleflash2" ); // FIXME - create DmeMultiMaterialSpriteEmitter to support the 4 materials of muzzleflash
pEmitter->SetInt( "active", true );
KeyValues *pInitializers = pEmitter->FindKey( "initializers", true );
KeyValues *pPosition = pInitializers->FindKey( "DmeLinearAttachedPositionInitializer", true );
pPosition->SetPtr( "entindex", (void*)pEnt->entindex() );
pPosition->SetInt( "attachmentIndex", attachmentIndex );
pPosition->SetFloat( "linearOffsetX", 2.0f * scale );
// TODO - create a DmeConstantLifetimeInitializer
KeyValues *pLifetime = pInitializers->FindKey( "DmeRandomLifetimeInitializer", true );
pLifetime->SetFloat( "minLifetime", bOneFrame ? 1.0f / 24.0f : 0.1f );
pLifetime->SetFloat( "maxLifetime", bOneFrame ? 1.0f / 24.0f : 0.1f );
KeyValues *pVelocity = pInitializers->FindKey( "DmeConstantVelocityInitializer", true );
pVelocity->SetFloat( "velocityX", 0.0f );
pVelocity->SetFloat( "velocityY", 0.0f );
pVelocity->SetFloat( "velocityZ", 0.0f );
KeyValues *pRoll = pInitializers->FindKey( "DmeRandomRollInitializer", true );
pRoll->SetFloat( "minRoll", 0.0f );
pRoll->SetFloat( "maxRoll", 360.0f );
// TODO - create a DmeConstantRollSpeedInitializer
KeyValues *pRollSpeed = pInitializers->FindKey( "DmeRandomRollSpeedInitializer", true );
pRollSpeed->SetFloat( "minRollSpeed", 0.0f );
pRollSpeed->SetFloat( "maxRollSpeed", 0.0f );
// TODO - create a DmeConstantColorInitializer
KeyValues *pColor = pInitializers->FindKey( "DmeRandomInterpolatedColorInitializer", true );
Color color( pFlashColor ? pFlashColor[ 0 ] : 255, pFlashColor ? pFlashColor[ 1 ] : 255, pFlashColor ? pFlashColor[ 2 ] : 255, 255 );
pColor->SetColor( "color1", color );
pColor->SetColor( "color2", color );
// TODO - create a DmeConstantAlphaInitializer
KeyValues *pAlpha = pInitializers->FindKey( "DmeRandomAlphaInitializer", true );
pAlpha->SetInt( "minStartAlpha", 255 );
pAlpha->SetInt( "maxStartAlpha", 255 );
pAlpha->SetInt( "minEndAlpha", 128 );
pAlpha->SetInt( "maxEndAlpha", 128 );
// size = rand(6..9) * indexed(12/9..4/9) * flScale = rand(6..9) * ( 4f + f * i )
KeyValues *pSize = pInitializers->FindKey( "DmeMuzzleFlashSizeInitializer", true );
float f = flScale / 9.0f;
pSize->SetFloat( "indexedBase", 4.0f * f );
pSize->SetFloat( "indexedDelta", f );
pSize->SetFloat( "minRandomFactor", 6.0f );
pSize->SetFloat( "maxRandomFactor", 9.0f );
/*
KeyValues *pUpdaters = pEmitter->FindKey( "updaters", true );
pUpdaters->FindKey( "DmePositionVelocityUpdater", true );
pUpdaters->FindKey( "DmeRollUpdater", true );
pUpdaters->FindKey( "DmeAlphaLinearUpdater", true );
pUpdaters->FindKey( "DmeSizeUpdater", true );
*/
ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
msg->deleteThis();
}
示例12: BuildMapFromLayoutFile
//Logic from CASW_Random_Missions::BuildAndLaunchRandomLevel
void MOD_Level_Builder::BuildMapFromLayoutFile( const char *szMissionRuleFile, const char *szOutputLayoutFile, const char *szThemeName, bool bCompileLevel)
{
if (IsBuildingLevel())
{
Msg("mod_level_builder is already building a level!\n");
return;
}
Msg("Building Map. MR File: [%s], Layout File: [%s], Theme: [%s]\n\n",
szMissionRuleFile, szOutputLayoutFile, szThemeName);
/*Code taken from TileGenDialog.cpp*/
KeyValues *pGenerationOptions = new KeyValues("EmptyOptions");
pGenerationOptions->Clear();
pGenerationOptions->LoadFromFile(g_pFullFileSystem, szMissionRuleFile, GAME_DIRECTORY);
CLayoutSystem *pLayoutSystem = new CLayoutSystem();
CTilegenMissionPreprocessor *pMissionPreprocessor = new CTilegenMissionPreprocessor();
CASW_KeyValuesDatabase *pRulesDatabase = new CASW_KeyValuesDatabase();
pRulesDatabase->LoadFiles( "tilegen/rules/" );
for ( int i = 0; i < pRulesDatabase->GetFileCount(); ++ i )
{
pMissionPreprocessor->ParseAndStripRules( pRulesDatabase->GetFile( i ) );
}
if (pMissionPreprocessor->SubstituteRules(pGenerationOptions) )
{
KeyValues *pMissionSettings = pGenerationOptions->FindKey( "mission_settings" );
if ( pMissionSettings == NULL )
{
Warning("Mission is missing a Global Options Block!\n");
return;
}
// Copy the filename key over
pMissionSettings->SetString( "Filename", pGenerationOptions->GetString( "Filename", "invalid_filename" ) );
AddListeners( pLayoutSystem );
if ( !pLayoutSystem->LoadFromKeyValues( pGenerationOptions ) )
{
Warning("Failed to load mission from pre-processed key-values.");
return;
}
int safteyCounter = 0;
CMapLayout *pMapLayout = NULL;
while (pMapLayout == NULL)
{
pMapLayout = GenerateMapLayout(pLayoutSystem, pMissionSettings);
safteyCounter++;
if (safteyCounter > 10)
{
Warning("MOD_Level_Builder failed generating a layout from layout file [%s]", szMissionRuleFile);
return;
}
}
char* fullPath = (char*)malloc(sizeof(char)*1024);
strcat(fullPath, g_gamedir);
strcat(fullPath, szOutputLayoutFile);
Q_strcpy(pMapLayout->m_szFilename, fullPath);
Msg("Saving layout file to [%s]", fullPath);
if (!pMapLayout->SaveMapLayout( fullPath ))
{
Warning("Failed to save Layout file to [%s]", fullPath);
return;
}
if (bCompileLevel)
CompileLevel(szOutputLayoutFile);
}
else
{
Warning("Failed Initializting Mission Preprocessor\n");
return;
}
}
示例13: PopulateControls
//.........这里部分代码省略.........
// Add the scenario to the list if not __init__
if ( !Q_stristr( pFilename, "__init__") )
{
Q_FileBase( pFilename, file, 32 );
scenariolist->AddItem( file, new KeyValues(file) );
}
pFilename = filesystem->FindNext( findHandle );
}
filesystem->FindClose( findHandle );
scenariolist->SetEditable( false );
scenariolist->SetNumberOfEditLines( 10 );
scenariolist->GetMenu()->ForceCalculateWidth();
scenariolist->ActivateItemByRow( 0 );
}
// Populate the bot difficulty list
ComboBox *botdifflist = dynamic_cast<ComboBox*>( FindChildByName("BotLevel") );
if ( botdifflist && botdifflist->GetItemCount() == 0 )
{
// Hard coded items (sorry!)
botdifflist->AddItem( "#BOT_LEVEL_EASY", new KeyValues("1") );
botdifflist->AddItem( "#BOT_LEVEL_MED", new KeyValues("3") );
botdifflist->AddItem( "#BOT_LEVEL_HARD", new KeyValues("6") );
botdifflist->AddItem( "#BOT_LEVEL_UBER", new KeyValues("9") );
// Admin
botdifflist->SetEditable( false );
botdifflist->SetNumberOfEditLines( 4 );
botdifflist->GetMenu()->ForceCalculateWidth();
botdifflist->ActivateItemByRow( 0 );
}
// Populate the turbo mode list
ComboBox *turbolist = dynamic_cast<ComboBox*>( FindChildByName("TurboMode") );
if ( turbolist && turbolist->GetItemCount() == 0 )
{
// Hard coded items (sorry!)
turbolist->AddItem( "#TURBO_MODE_NORM", new KeyValues("1.000000") );
turbolist->AddItem( "#TURBO_MODE_FAST", new KeyValues("1.500000") );
turbolist->AddItem( "#TURBO_MODE_LIGHT", new KeyValues("1.850000") );
// Admin
turbolist->SetEditable( false );
turbolist->SetNumberOfEditLines( 3 );
turbolist->GetMenu()->ForceCalculateWidth();
turbolist->ActivateItemByRow( 0 );
}
// Load the default/saved values from our command map
for ( KeyValues *kv = m_kvCmdMap->GetFirstTrueSubKey(); kv; kv = kv->GetNextTrueSubKey() )
{
// Get our value (or default)
const char *value = (m_kvCmdValues->FindKey( kv->GetName() )) ? m_kvCmdValues->GetString( kv->GetName() ) : NULL;
if ( !value )
value = kv->GetString( "default", "" );
if ( !Q_stricmp(kv->GetString("type"), "CHOICE") )
{
ComboBox *panel = dynamic_cast<ComboBox*>( FindChildByName(kv->GetName()) );
if ( !panel )
continue;
// Search through all our items to find a matching value
for ( int i=0; i < panel->GetItemCount(); i++ )
{
int id = panel->GetItemIDFromRow( i );
KeyValues* userdata = panel->GetItemUserData( id );
if ( userdata && !Q_stricmp(value, userdata->GetName()) )
{
panel->ActivateItem( id );
break;
}
}
}
else if ( !Q_stricmp(kv->GetString("type"), "TEXT") )
{
TextEntry *panel = dynamic_cast<TextEntry*>( FindChildByName(kv->GetName()) );
if ( !panel )
continue;
panel->SetText( value );
}
else if ( !Q_stricmp(kv->GetString("type"), "BOOL") )
{
CheckButton *panel = dynamic_cast<CheckButton*>( FindChildByName(kv->GetName()) );
if ( !panel )
continue;
if ( !Q_stricmp(value, "1") )
panel->SetSelected( true );
else
panel->SetSelected( false );
}
}
m_bFirstLoad = false;
}
示例14: OnCommand
void CGECreateServer::OnCommand( const char *command )
{
if ( !Q_stricmp(command, "play") )
{
CUtlVector<char*> commands;
// Pull the values from our controls and apply them to commands and save off the choices
for ( KeyValues *kv = m_kvCmdMap->GetFirstTrueSubKey(); kv; kv = kv->GetNextTrueSubKey() )
{
KeyValues *kv_value = m_kvCmdValues->FindKey( kv->GetName(), true );
char *cmd = new char[128];
try {
if ( !Q_stricmp(kv->GetString("type"), "CHOICE") )
{
ComboBox *panel = dynamic_cast<ComboBox*>( FindChildByName(kv->GetName()) );
const char *cmd_value = panel->GetActiveItemUserData()->GetName();
kv_value->SetStringValue( cmd_value );
if ( !Q_stricmp(cmd_value, RANDOM_VALUE) )
{
int idx = GERandom<int>( panel->GetItemCount()-1 ) + 1;
idx = panel->GetItemIDFromRow( idx );
cmd_value = panel->GetItemUserData( idx )->GetName();
}
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), cmd_value );
commands.AddToTail( cmd );
}
else if ( !Q_stricmp(kv->GetString("type"), "TEXT") )
{
char cmd_value[64];
TextEntry *panel = dynamic_cast<TextEntry*>( FindChildByName(kv->GetName()) );
panel->GetText( cmd_value, 64 );
// We don't allow blank values... use default instead
if ( !cmd_value[0] )
Q_strncpy( cmd_value, kv->GetString("default",""), 64 );
kv_value->SetStringValue( cmd_value );
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), cmd_value );
commands.AddToTail( cmd );
}
else if ( !Q_stricmp(kv->GetString("type"), "BOOL") )
{
CheckButton *panel = dynamic_cast<CheckButton*>( FindChildByName(kv->GetName()) );
if ( panel->IsSelected() ) {
kv_value->SetStringValue( "1" );
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), kv->GetString("on_val","1") );
} else {
kv_value->SetStringValue( "0" );
Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), kv->GetString("off_val","0") );
}
commands.AddToTail( cmd );
}
else
{
delete [] cmd;
}
} catch (...) {
delete [] cmd;
}
}
// Apply the commands
for ( int i=0; i < commands.Count(); i++ )
engine->ClientCmd_Unrestricted( commands[i] );
// Save our last used settings to our custom file
m_kvCmdValues->SaveToFile( filesystem, COMMAND_MAP_VAL, "MOD" );
// Cleanup
commands.PurgeAndDeleteElements();
}
SetVisible( false );
}
示例15: PerformLayout
//---------------------------------------------------------------------
// Purpose: Center the dialog on the screen
//---------------------------------------------------------------------
void CSessionLobbyDialog::PerformLayout()
{
BaseClass::PerformLayout();
if ( !m_pDialogKeys )
return;
// Set the label strings according to the keyvalues passed in
SetTextFromKeyvalues( m_pScenarioInfo->m_pTitle );
SetTextFromKeyvalues( m_pScenarioInfo->m_pDescOne );
SetTextFromKeyvalues( m_pScenarioInfo->m_pDescTwo );
SetTextFromKeyvalues( m_pScenarioInfo->m_pDescThree );
SetTextFromKeyvalues( m_pScenarioInfo->m_pValueTwo );
SetTextFromKeyvalues( m_pScenarioInfo->m_pValueThree );
const char *pDiskName = "unknown";
KeyValues *pName = m_pDialogKeys->FindKey( "MapDiskNames" );
if ( pName )
{
KeyValues *pScenario = m_pDialogKeys->FindKey( "CONTEXT_SCENARIO" );
if ( pScenario )
{
pDiskName = pName->GetString( pScenario->GetString( "displaystring" ), "unknown" );
}
}
// find the scenario type
KeyValues *pType = m_pDialogKeys->FindKey( "ScenarioTypes" );
if ( pType )
{
const char *pString = pType->GetString( pDiskName, NULL );
if ( pString )
{
m_pScenarioInfo->m_pSubtitle->SetText( pString );
}
}
// Set the team goals
KeyValues *pGoals = m_pDialogKeys->FindKey( "TeamGoals" );
if ( pGoals )
{
KeyValues *pTeam = pGoals->FindKey( "Blue" );
if ( pTeam )
{
m_pTeamInfos[BLUE_TEAM_LOBBY]->m_pDescOne->SetText( pTeam->GetString( pDiskName, "" ) );
}
pTeam = pGoals->FindKey( "Red" );
if ( pTeam )
{
m_pTeamInfos[RED_TEAM_LOBBY]->m_pDescOne->SetText( pTeam->GetString( pDiskName, "" ) );
}
}
for ( int i = 0; i < TOTAL_LOBBY_TEAMS; ++i )
{
UpdatePlayerCountDisplay( i );
}
if ( m_bCenterOnScreen )
{
MoveToCenterOfScreen();
}
// Don't allow player reviews in system link games
CMatchmakingBasePanel *pBase = dynamic_cast< CMatchmakingBasePanel* >( m_pParent );
if ( pBase )
{
pBase->SetFooterButtonVisible( "#GameUI_PlayerReview", pBase->GetGameType() != GAMETYPE_SYSTEMLINK_MATCH );
// hide the settings changing if we're in a ranked game
if ( m_pHostOptionsPanel )
{
bool bVisible = pBase->GetGameType() != GAMETYPE_RANKED_MATCH;
vgui::Label *pSettingsLabel = (vgui::Label *)m_pHostOptionsPanel->FindChildByName("ChangeSettingsButton",true);
if ( pSettingsLabel )
{
pSettingsLabel->SetVisible( bVisible );
}
pSettingsLabel = (vgui::Label *)m_pHostOptionsPanel->FindChildByName("ChangeSettingsText",true);
if ( pSettingsLabel )
{
pSettingsLabel->SetVisible( bVisible );
}
}
}
}