KeyValues* CASW_Location_Group::GetKeyValuesForEditor() { char buffer[64]; KeyValues *pKeys = new KeyValues( "Group" ); pKeys->SetInt( "RequiredUnlocks", m_iRequiredUnlocks ); Q_snprintf( buffer, sizeof( buffer ), "%d %d %d %d", m_Color.r(), m_Color.g(), m_Color.b(), m_Color.a() ); pKeys->SetString( "Color", buffer ); pKeys->SetString( "Name", m_szGroupName ); pKeys->SetString( "TitleText", m_szTitleText ); pKeys->SetString( "DescriptionText", m_szDescriptionText ); pKeys->SetString( "ImageName", m_szImageName ); for ( int i = 0; i < m_UnlockedBy.Count(); i++ ) { KeyValues *pKey = new KeyValues( "UnlockMissionID" ); Q_snprintf( buffer, sizeof( buffer ), "%d", m_UnlockedBy[i] ); pKey->SetStringValue( buffer ); pKeys->AddSubKey( pKey ); } for ( int i = 0; i < m_Locations.Count(); i++ ) { KeyValues *pKey = m_Locations[i]->GetKeyValuesForEditor(); pKeys->AddSubKey( pKey ); } return pKeys; }
//----------------------------------------------------------------------------- // Purpose: handles button commands //----------------------------------------------------------------------------- void InputDialog::OnCommand(const char *command) { // overriding OnCommand for backwards compatability // it'd be nice at some point to find all uses of InputDialog and just use BaseInputDialog's OnCommand if (!stricmp(command, "OK")) { int nTextLength = m_pInput->GetTextLength() + 1; char* txt = (char*)_alloca( nTextLength * sizeof(char) ); m_pInput->GetText( txt, nTextLength ); KeyValues *kv = new KeyValues( "InputCompleted", "text", txt ); if ( m_pContextKeyValues ) { kv->AddSubKey( m_pContextKeyValues ); m_pContextKeyValues = NULL; } PostActionSignal( kv ); CloseModal(); } else if (!stricmp(command, "Cancel")) { KeyValues *kv = new KeyValues( "InputCanceled" ); if ( m_pContextKeyValues ) { kv->AddSubKey( m_pContextKeyValues ); m_pContextKeyValues = NULL; } PostActionSignal( kv ); CloseModal(); } else { BaseClass::OnCommand(command); } }
//----------------------------------------------------------------------------- // Purpose: handles button commands //----------------------------------------------------------------------------- void InputDialog::OnCommand(const char *command) { if (!stricmp(command, "OK")) { int nTextLength = m_pInput->GetTextLength() + 1; char* txt = (char*)_alloca( nTextLength * sizeof(char) ); m_pInput->GetText( txt, nTextLength ); KeyValues *kv = new KeyValues( "InputCompleted", "text", txt ); if ( m_pContextKeyValues ) { kv->AddSubKey( m_pContextKeyValues ); m_pContextKeyValues = NULL; } PostActionSignal( kv ); CloseModal(); } else if (!stricmp(command, "Cancel")) { KeyValues *kv = new KeyValues( "InputCanceled" ); if ( m_pContextKeyValues ) { kv->AddSubKey( m_pContextKeyValues ); m_pContextKeyValues = NULL; } PostActionSignal( kv ); CloseModal(); } else { BaseClass::OnCommand(command); } }
KeyValues *InstantiateRule( const CTilegenMissionPreprocessor *pPreprocessor, const char *pRuleName ) { const CTilegenRule *pRule = pPreprocessor->FindRule( pRuleName ); if ( pRule != NULL ) { KeyValues *pNewKV = new KeyValues( "rule_instance", "name", pRuleName ); for ( int i = 0; i < pRule->GetParameterCount(); ++ i ) { if ( !pRule->IsParameterOptional( i ) ) { const KeyValues *pDefaultValue = pRule->GetDefaultValue( i ); KeyValues *pRuleInstanceParameter = new KeyValues( pRule->GetParameterName( i ) ); if ( pDefaultValue != NULL ) { pRuleInstanceParameter->AddSubKey( pDefaultValue->MakeCopy() ); } else { pRuleInstanceParameter->SetString( NULL, "<Enter Value>" ); } pNewKV->AddSubKey( pRuleInstanceParameter ); } } return pNewKV; } return NULL; }
bool CRoomTemplate::SaveRoomTemplate() { if (!m_pLevelTheme) return false; char szThemeDirName[MAX_PATH]; Q_snprintf(szThemeDirName, sizeof(szThemeDirName), "tilegen/roomtemplates/%s", m_pLevelTheme->m_szName); g_pFullFileSystem->CreateDirHierarchy( szThemeDirName, "GAME" ); char szFullFileName[MAX_PATH]; Q_snprintf( szFullFileName, sizeof(szFullFileName), "tilegen/roomtemplates/%s/%s.roomtemplate", m_pLevelTheme->m_szName, m_FullName ); KeyValues *pRoomTemplateKeyValues = new KeyValues( m_FullName ); pRoomTemplateKeyValues->SetInt( "TilesX", m_nTilesX ); pRoomTemplateKeyValues->SetInt( "TilesY", m_nTilesY ); pRoomTemplateKeyValues->SetInt( "SpawnWeight", m_nSpawnWeight ); pRoomTemplateKeyValues->SetString( "RoomTemplateDescription", m_Description ); pRoomTemplateKeyValues->SetString( "Soundscape", m_Soundscape ); pRoomTemplateKeyValues->SetInt( "TileType", m_nTileType ); // exits int iExits = m_Exits.Count(); for (int i=0; i<iExits; i++) { KeyValues *pkvSubSection = new KeyValues("EXIT"); pkvSubSection->SetInt("XPos", m_Exits[i]->m_iXPos); pkvSubSection->SetInt("YPos", m_Exits[i]->m_iYPos); pkvSubSection->SetInt("ExitDirection", (int) m_Exits[i]->m_ExitDirection); pkvSubSection->SetInt("ZChange", m_Exits[i]->m_iZChange); pkvSubSection->SetString("ExitTag", m_Exits[i]->m_szExitTag); pkvSubSection->SetBool("ChokeGrow", m_Exits[i]->m_bChokepointGrowSource); pRoomTemplateKeyValues->AddSubKey(pkvSubSection); } // tags KeyValues *pkvSubSection = new KeyValues("Tags"); for ( int i=0; i<GetNumTags(); i++ ) { pkvSubSection->AddSubKey( new KeyValues( "tag", NULL, GetTag( i ) ) ); } pRoomTemplateKeyValues->AddSubKey(pkvSubSection); if (!pRoomTemplateKeyValues->SaveToFile(g_pFullFileSystem, szFullFileName, "GAME")) { Msg("Error: Failed to save room template %s\n", szFullFileName); return false; } return true; }
/* char *name; bool bStatic; int min; int max; */ KeyValues *__AllocKV_Identifiers( IdentifierLists_t *pList ) { KeyValues *pIdents = new KeyValues(""); for ( int i = 0; i < pList->hList_Combos.Count(); i++ ) pIdents->AddSubKey( __AllocKV_Combo( i, pList->hList_Combos[i] ) ); for ( int i = 0; i < pList->hList_EConstants.Count(); i++ ) pIdents->AddSubKey( __AllocKV_EConst( i, pList->hList_EConstants[i] ) ); for ( int i = 0; i < pList->hList_Textures.Count(); i++ ) pIdents->AddSubKey( __AllocKV_Texture( i, pList->hList_Textures[i] ) ); pIdents->SetInt( "i_numdcombos", pList->inum_DynamicCombos ); return pIdents; }
//----------------------------------------------------------------------------- // Purpose: handles button commands //----------------------------------------------------------------------------- void BaseInputDialog::OnCommand(const char *command) { KeyValues *kv = NULL; if ( !stricmp( command, "OK" ) ) { kv = new KeyValues( "InputCompleted" ); kv->SetPtr( "dialog", this ); } else if ( !stricmp( command, "Cancel" ) ) { kv = new KeyValues( "InputCanceled" ); } else { BaseClass::OnCommand( command ); return; } if ( m_pContextKeyValues ) { kv->AddSubKey( m_pContextKeyValues ); m_pContextKeyValues = NULL; } PostActionSignal( kv ); CloseModal(); }
//Called every time a new time is achieved void CTimer::SaveTime() { const char *szMapName = gpGlobals->mapname.ToCStr(); KeyValues *timesKV = new KeyValues(szMapName); int count = localTimes.Count(); for (int i = 0; i < count; i++) { Time t = localTimes[i]; char timeName[512]; Q_snprintf(timeName, 512, "%i", t.ticks); KeyValues *pSubkey = new KeyValues(timeName); pSubkey->SetFloat("rate", t.tickrate); pSubkey->SetInt("date", t.date); timesKV->AddSubKey(pSubkey); } char file[MAX_PATH]; Q_strcpy(file, c_mapDir); Q_strcat(file, szMapName, MAX_PATH); Q_strncat(file, c_timesExt, MAX_PATH); if (timesKV->SaveToFile(filesystem, file, "MOD", true)) { Log("Successfully saved new time!\n"); IGameEvent *savedEvent = gameeventmanager->CreateEvent("runtime_saved"); if (savedEvent) gameeventmanager->FireEvent(savedEvent); } timesKV->deleteThis(); }
//----------------------------------------------------------------------------- // Purpose: Delete selected entities/props. //----------------------------------------------------------------------------- void CEditorSystem::DeleteSelection() { if( !IsAnythingSelected() ) return; KeyValues *pOperation = new KeyValues( "data" ); pOperation->SetString("operation", "deleteflora"); for( int i = 0; i < m_hSelectedEntities.Count(); i++ ) { if( !m_hSelectedEntities[i] ) continue; CWarsFlora *pFlora = dynamic_cast<CWarsFlora *>( m_hSelectedEntities[i].Get() ); if( pFlora ) { pOperation->AddSubKey( new KeyValues( "flora", "uuid", pFlora->GetFloraUUID() ) ); pFlora->Remove(); } else { m_hSelectedEntities[i]->Remove(); } } m_hSelectedEntities.Purge(); warseditorstorage->QueueClientCommand( pOperation ); }
//----------------------------------------------------------------------------- // Process commands //----------------------------------------------------------------------------- void CSaveDocumentQuery::OnCommand( char const *cmd ) { if ( !Q_stricmp( cmd, "yes" ) ) { KeyValues *kv = new KeyValues( "OnSaveFile" ); kv->SetString( "filename", m_szFileName ); kv->SetString( "filetype", m_szFileType ); kv->SetInt( "context", m_nContext ); kv->SetPtr( "actionTarget", m_pActionSignalTarget ); if ( m_pPostSaveKeyValues ) { kv->AddSubKey( m_pPostSaveKeyValues->MakeCopy() ); } vgui::ivgui()->PostMessage( m_pActionSignalTarget->GetVPanel(), kv, 0 ); MarkForDeletion(); } else if ( !Q_stricmp( cmd, "no" ) ) { PostCommand( "OnMarkNotDirty" ); if ( m_pPostSaveKeyValues ) { vgui::ivgui()->PostMessage( m_pActionSignalTarget->GetVPanel(), m_pPostSaveKeyValues->MakeCopy(), 0 ); } MarkForDeletion(); } else if ( !Q_stricmp( cmd, "cancel" ) ) { PostCommand( "OnCancelSaveDocument" ); MarkForDeletion(); } else { BaseClass::OnCommand( cmd ); } }
//----------------------------------------------------------------------------- // On command //----------------------------------------------------------------------------- void CDmeLogEditFrame::OnCommand( const char *pCommand ) { if ( !Q_stricmp( pCommand, "Ok" ) ) { KeyValues *pActionKeys = new KeyValues( "LogEdited" ); if ( m_pContextKeyValues ) { pActionKeys->AddSubKey( m_pContextKeyValues ); // This prevents them from being deleted later m_pContextKeyValues = NULL; } PostActionSignal( pActionKeys ); CloseModal(); return; } if ( !Q_stricmp( pCommand, "Cancel" ) ) { CloseModal(); return; } BaseClass::OnCommand( pCommand ); }
void CRoomTemplateListPanel::AddFolder( const char *pFolderName ) { int nNumFolders = m_RoomTemplateFolders.Count(); for ( int i = 0; i < nNumFolders; ++ i ) { if ( Q_stricmp( pFolderName, m_RoomTemplateFolders[i].m_FolderName ) == 0 ) { // Mark this folder as being used m_RoomTemplateFolders[i].m_pFolderButton->SetVisible( true ); return; } } // New folder, create a new entry m_RoomTemplateFolders.AddToTail(); Q_strncpy( m_RoomTemplateFolders[nNumFolders].m_FolderName, pFolderName, MAX_PATH ); m_RoomTemplateFolders[nNumFolders].m_bExpanded = true; m_RoomTemplateFolders[nNumFolders].m_pFolderButton = new Button( this, "FolderButton", "", this, "ToggleFolder" ); KeyValues *pMessageKV = new KeyValues( "ToggleFolder" ); KeyValues *pIndexKV = new KeyValues( "folder" ); pIndexKV->SetString( NULL, m_RoomTemplateFolders[nNumFolders].m_FolderName ); pMessageKV->AddSubKey( pIndexKV ); m_RoomTemplateFolders[nNumFolders].m_pFolderButton->SetCommand( pMessageKV ); }
// Load the control settings void CBaseModFrame::LoadControlSettings( const char *dialogResourceName, const char *pathID, KeyValues *pPreloadedKeyValues, KeyValues *pConditions ) { // Use the keyvalues they passed in or load them using special hook for flyouts generation KeyValues *rDat = pPreloadedKeyValues; if ( !rDat ) { // load the resource data from the file rDat = new KeyValues(dialogResourceName); // check the skins directory first, if an explicit pathID hasn't been set bool bSuccess = false; if ( !IsX360() && !pathID ) { bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, "SKIN" ); } if ( !bSuccess ) { bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, pathID ); } if ( bSuccess ) { if ( IsX360() ) { rDat->ProcessResolutionKeys( surface()->GetResolutionKey() ); } if ( pConditions && pConditions->GetFirstSubKey() ) { GetBuildGroup()->ProcessConditionalKeys( rDat, pConditions ); } } } // Find the auto-generated-chapter hook if ( KeyValues *pHook = rDat->FindKey( "FlmChapterXXautogenerated" ) ) { const int numMaxAutogeneratedFlyouts = 20; for ( int k = 1; k <= numMaxAutogeneratedFlyouts; ++ k ) { KeyValues *pFlyoutInfo = pHook->MakeCopy(); CFmtStr strName( "FlmChapter%d", k ); pFlyoutInfo->SetName( strName ); pFlyoutInfo->SetString( "fieldName", strName ); pFlyoutInfo->SetString( "ResourceFile", CFmtStr( "FlmChapterXXautogenerated_%d/%s", k, pHook->GetString( "ResourceFile" ) ) ); rDat->AddSubKey( pFlyoutInfo ); } rDat->RemoveSubKey( pHook ); pHook->deleteThis(); } BaseClass::LoadControlSettings( dialogResourceName, pathID, rDat, pConditions ); if ( rDat != pPreloadedKeyValues ) { rDat->deleteThis(); } }
/* CUtlVector< SimpleTexture* > hList_Textures; CUtlVector< SimpleCombo* > hList_Combos; CUtlVector< SimpleEnvConstant* > hList_EConstants; */ void df_SaveDump_File( const char *canvasname, const BasicShaderCfg_t &shader ) { KeyValues *pKV = new KeyValues( canvasname ); char _path[MAX_PATH]; Q_snprintf( _path, MAX_PATH, "%s/%s.dump", ::GetDumpDirectory(), canvasname ); Q_FixSlashes( _path ); pKV->SetString( "vs_name", shader.ProcVSName ); pKV->SetString( "ps_name", shader.ProcPSName ); pKV->SetString( "shader_filename", shader.Filename ); pKV->SetString( GetDumpVersion_KeyName(), GetDumpVersion_Current() ); pKV->SetInt( "i_sm", shader.iShaderModel ); pKV->SetInt( "i_cull", shader.iCullmode ); pKV->SetInt( "i_ablend", shader.iAlphablendmode ); pKV->SetFloat( "fl_atestref", shader.flAlphaTestRef ); pKV->SetInt( "i_dtest", shader.iDepthtestmode ); pKV->SetInt( "i_dwrite", shader.iDepthwritemode ); pKV->SetInt( "i_srgbw", shader.bsRGBWrite ? 1 : 0 ); pKV->SetInt( "i_vfmt_flags", shader.iVFMT_flags ); pKV->SetInt( "i_vfmt_texcoords", shader.iVFMT_numTexcoords ); pKV->SetInt( "i_vfmt_udata", shader.iVFMT_numUserData ); for ( int i = 0; i < 3; i++ ) { char tmp[48]; Q_snprintf( tmp, sizeof(tmp), "i_vfmt_texcoordDim_%i", i ); pKV->SetInt( tmp, shader.iVFMT_texDim[i] ); } pKV->SetInt( "i_vlit", shader.bVertexLighting ); pKV->SetInt( "i_vrefract", shader.bRefractionSupport ); KeyValues *pKVIdentVS = __AllocKV_Identifiers( shader.pVS_Identifiers ); pKVIdentVS->SetName( "identifiers_VS" ); pKV->AddSubKey( pKVIdentVS ); KeyValues *pKVIdentPS = __AllocKV_Identifiers( shader.pPS_Identifiers ); pKVIdentPS->SetName( "identifiers_PS" ); pKV->AddSubKey( pKVIdentPS ); pKV->SaveToFile( g_pFullFileSystem, _path, "MOD" ); pKV->deleteThis(); }
void UTIL_IncrementMapKey( const char *pszCustomKey ) { if ( !pszCustomKey ) return; char szFilename[ _MAX_PATH ]; if ( !UTIL_GetMapLoadCountFileName( MAP_KEY_FILE, szFilename, _MAX_PATH ) ) return; int iCount = 1; KeyValues *kvMapLoadFile = new KeyValues( MAP_KEY_FILE ); if ( kvMapLoadFile ) { kvMapLoadFile->LoadFromFile( g_pFullFileSystem, szFilename, "MOD" ); char mapname[MAX_MAP_NAME]; Q_FileBase( engine->GetLevelName(), mapname, sizeof( mapname) ); Q_strlower( mapname ); // Increment existing, or add a new one KeyValues *pMapKey = kvMapLoadFile->FindKey( mapname ); if ( pMapKey ) { iCount = pMapKey->GetInt( pszCustomKey, 0 ) + 1; pMapKey->SetInt( pszCustomKey, iCount ); } else { KeyValues *pNewKey = new KeyValues( mapname ); if ( pNewKey ) { pNewKey->SetString( pszCustomKey, "1" ); kvMapLoadFile->AddSubKey( pNewKey ); } } // Write it out // force create this directory incase it doesn't exist filesystem->CreateDirHierarchy( MAP_KEY_FILE_DIR, "MOD"); CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER ); kvMapLoadFile->RecursiveSaveToFile( buf, 0 ); g_pFullFileSystem->WriteFile( szFilename, "MOD", buf ); kvMapLoadFile->deleteThis(); } if ( IsX360() ) { #ifdef _X360 xboxsystem->FinishContainerWrites(); #endif } }
KeyValues* VMFExporter::GetDefaultCamera() { KeyValues *pKeys = new KeyValues( "cameras" ); pKeys->SetInt( "activecamera", 0 ); KeyValues *pSubKeys = new KeyValues( "camera" ); pSubKeys->SetString( "position", "[135.491 -60.314 364.02]" ); pSubKeys->SetString( "look", "[141.195 98.7571 151.25]" ); pKeys->AddSubKey( pSubKeys ); return pKeys; }
void CRulePickerDialog::OnRuleDetailsClicked( vgui::Panel *pPanel ) { CRuleDetailsPanel *pRuleDetails = dynamic_cast< CRuleDetailsPanel * >( pPanel ); Assert( pPanel != NULL ); KeyValues *pNewRuleInstance = InstantiateRule( m_pRulePreprocessor, pRuleDetails->GetRule()->GetName() ); if ( pNewRuleInstance != NULL ) { KeyValues *pMessage = new KeyValues( "RuleChanged" ); pMessage->AddSubKey( pNewRuleInstance ); PostActionSignal( pMessage ); } OnClose(); }
KeyValues* CASW_Location::GetKeyValuesForEditor() { KeyValues *pKeys = new KeyValues( "Location" ); pKeys->SetInt( "x", m_iXPos ); pKeys->SetInt( "y", m_iYPos ); pKeys->SetInt( "MinDifficulty", m_iMinDifficulty ); pKeys->SetInt( "MaxDifficulty", m_iMaxDifficulty ); pKeys->SetString( "StoryScene", m_szStoryScene ); pKeys->SetString( "ImageName", m_szImageName ); // if mission doesn't have a valid ID then find one if ( m_iLocationID == -1 ) { m_iLocationID = LocationGrid()->GetFreeLocationID(); } pKeys->SetInt( "ID", m_iLocationID ); pKeys->SetString( "CustomMission", m_pszCustomMission ); pKeys->SetInt( "Company", m_iCompanyIndex ); //pKeys->SetInt( "MoneyReward", m_iMoneyReward ); //pKeys->SetInt( "XPReward", m_iXPReward ); pKeys->SetInt( "Optional", m_bIsMissionOptional ); if ( m_Rewards.Count() > 0 ) { KeyValues *pRewards = new KeyValues( "Rewards"); pKeys->AddSubKey( pRewards ); for ( int i = 0; i < m_Rewards.Count(); i++ ) { KeyValues *pReward = m_Rewards[i]->GetKeyValuesForEditor(); if ( pReward ) { pRewards->AddSubKey( pReward ); } } } return pKeys; }
void CTileGenDialog::GenerateRoomThumbnails( bool bAddToPerforce ) { // save out a keyvalues file with position/size of each room KeyValues *pKV = new KeyValues( "RoomThumbnails" ); char filename[MAX_PATH]; for ( int i=0;i<m_pMapLayout->m_PlacedRooms.Count();i++ ) { CRoom *pRoom = m_pMapLayout->m_PlacedRooms[i]; if ( !pRoom ) continue; KeyValues *pkvEntry = new KeyValues( "Thumbnail" ); Q_snprintf( filename, sizeof( filename ), "tilegen/roomtemplates/%s/%s.tga", pRoom->m_pRoomTemplate->m_pLevelTheme->m_szName, pRoom->m_pRoomTemplate->GetFullName() ); pkvEntry->SetString( "Filename", filename ); int half_map_size = MAP_LAYOUT_TILES_WIDE * 0.5f; // shift back so the middle of our grid is the origin float xPos = (pRoom->m_iPosX - half_map_size) * ASW_TILE_SIZE; float yPos = (pRoom->m_iPosY - half_map_size) * ASW_TILE_SIZE; pkvEntry->SetFloat( "RoomX", xPos ); pkvEntry->SetFloat( "RoomY", yPos + pRoom->m_pRoomTemplate->GetTilesY() * ASW_TILE_SIZE ); pkvEntry->SetFloat( "RoomWide", pRoom->m_pRoomTemplate->GetTilesX() * ASW_TILE_SIZE ); pkvEntry->SetFloat( "RoomTall", pRoom->m_pRoomTemplate->GetTilesY() * ASW_TILE_SIZE ); pkvEntry->SetFloat( "OutputWide", pRoom->m_pRoomTemplate->GetTilesX() * RoomTemplatePanelTileSize() ); pkvEntry->SetFloat( "OutputTall", pRoom->m_pRoomTemplate->GetTilesY() * RoomTemplatePanelTileSize() ); pKV->AddSubKey( pkvEntry ); } if ( !pKV->SaveToFile( g_pFullFileSystem, THUMBNAILS_FILE, "GAME" ) ) { Msg( "Error: Couldn't save %s\n", THUMBNAILS_FILE ); pKV->deleteThis(); return; } pKV->deleteThis(); m_pMapLayout->SaveMapLayout( "maps/output.layout" ); if ( engine ) { char buffer[256]; Q_snprintf(buffer, sizeof(buffer), "asw_random_weapons 0; asw_building_room_thumbnails 1; asw_add_room_thumbnails_to_perforce %d; asw_build_map %s", bAddToPerforce ? 1 : 0, "output.layout" ); engine->ClientCmd_Unrestricted( buffer ); } }
bool VMFExporter::AddRoomTemplateSolids( const CRoomTemplate *pRoomTemplate ) { // open its vmf file char roomvmfname[MAX_PATH]; Q_snprintf(roomvmfname, sizeof(roomvmfname), "tilegen/roomtemplates/%s/%s.vmf", pRoomTemplate->m_pLevelTheme->m_szName, pRoomTemplate->GetFullName() ); m_pTemplateKeys = new KeyValues( "RoomTemplateVMF" ); m_pTemplateKeys->LoadFromFile( g_pFullFileSystem, roomvmfname, "GAME" ); // look for world key for ( KeyValues *pKeys = m_pTemplateKeys; pKeys; pKeys = pKeys->GetNextKey() ) { if ( !Q_stricmp( pKeys->GetName(), "world" ) ) // find the world key in our room template { if ( !ProcessWorld( pKeys ) ) // fix up solid positions { Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to copy world from room %s\n", pRoomTemplate->GetFullName() ); return false; } for ( KeyValues *pSubKey = pKeys->GetFirstSubKey(); pSubKey; pSubKey = pSubKey->GetNextKey() ) // convert each solid to a func_detail entity { if ( !Q_stricmp( pSubKey->GetName(), "solid" ) ) { if ( IsDisplacementBrush( pSubKey ) ) { // add to world section m_pExportWorldKeys->AddSubKey( pSubKey->MakeCopy() ); } else { // put into entity section as a func_detail KeyValues *pFuncDetail = new KeyValues( "entity" ); pFuncDetail->SetInt( "id", ++m_iEntityCount ); pFuncDetail->SetString( "classname", "func_detail" ); pFuncDetail->AddSubKey( pSubKey->MakeCopy() ); m_pExportKeys->AddSubKey( pFuncDetail ); } } } } } m_pTemplateKeys->deleteThis(); m_pTemplateKeys = NULL; return true; }
void CASWJukeboxPlaylist::ExportPlayistKV( void ) { KeyValues *pPlaylistKV = new KeyValues("playlist"); for( int i=0; i<m_CombatMusicPlaylist.Count(); ++i ) { KeyValues *pTrackKV = new KeyValues("Track"); pTrackKV->SetString( "TrackName", m_CombatMusicPlaylist[i].m_szFilename ); pTrackKV->SetString( "HexName", m_CombatMusicPlaylist[i].m_szHexname ); pTrackKV->SetString( "Album", m_CombatMusicPlaylist[i].m_szAlbum ); pTrackKV->SetString( "Artist", m_CombatMusicPlaylist[i].m_szArtist); pTrackKV->SetString( "Genre", m_CombatMusicPlaylist[i].m_szGenre ); pPlaylistKV->AddSubKey( pTrackKV ); } pPlaylistKV->SaveToFile( filesystem, sz_PlaylistFilename ); pPlaylistKV->deleteThis(); }
void BuildGroup::ProcessConditionalKeys( KeyValues *pData, KeyValues *pConditions ) { // for each condition, look for it in keys // if its a positive condition, promote all of its children, replacing values if ( pData ) { KeyValues *pSubKey = pData->GetFirstSubKey(); if ( !pSubKey ) { // not a block return; } for ( ; pSubKey != nullptr; pSubKey = pSubKey->GetNextKey() ) { // recursively descend each sub block ProcessConditionalKeys( pSubKey, pConditions ); KeyValues *pCondition = pConditions->GetFirstSubKey(); for ( ; pCondition != nullptr; pCondition = pCondition->GetNextKey() ) { // if we match any conditions in this sub block, copy up KeyValues *pConditionBlock = pSubKey->FindKey( pCondition->GetName() ); if ( pConditionBlock ) { KeyValues *pOverridingKey; for ( pOverridingKey = pConditionBlock->GetFirstSubKey(); pOverridingKey != nullptr; pOverridingKey = pOverridingKey->GetNextKey() ) { KeyValues *pExistingKey = pSubKey->FindKey( pOverridingKey->GetName() ); if ( pExistingKey ) { pExistingKey->SetStringValue( pOverridingKey->GetString() ); } else { KeyValues *copy = pOverridingKey->MakeCopy(); pSubKey->AddSubKey( copy ); } } } } } } }
//----------------------------------------------------------------------------- // Utility to set the completion state //----------------------------------------------------------------------------- void FileOpenStateMachine::SetCompletionState( FileOpenStateMachine::CompletionState_t state ) { m_CompletionState = state; if ( m_CompletionState == IN_PROGRESS ) return; m_CurrentState = STATE_NONE; KeyValues *kv = new KeyValues( "FileStateMachineFinished" ); kv->SetInt( "completionState", m_CompletionState ); kv->SetInt( "wroteFile", m_bWroteFile ); kv->SetString( "fullPath", m_FileName.Get() ); kv->SetString( "fileType", m_bIsOpeningFile ? m_OpenFileType.Get() : m_SaveFileType.Get() ); if ( m_pContextKeyValues ) { kv->AddSubKey( m_pContextKeyValues ); m_pContextKeyValues = NULL; } PostActionSignal( kv ); }
//----------------------------------------------------------------------------- // command handler //----------------------------------------------------------------------------- void CAddPresetDialog::OnCommand( const char *command ) { if ( !Q_stricmp( command, "OK" ) ) { int nTextLength = m_pInput->GetTextLength() + 1; char* txt = (char*)_alloca( nTextLength * sizeof(char) ); m_pInput->GetText( txt, nTextLength ); nTextLength = m_pPresetGroup->GetTextLength() + 1; char* pPresetGroupName = (char*)_alloca( nTextLength * sizeof(char) ); m_pPresetGroup->GetText( pPresetGroupName, nTextLength ); KeyValues *pCurrentGroup = m_pPresetGroup->GetActiveItemUserData(); CDmePresetGroup *pPresetGroup = pCurrentGroup ? GetElementKeyValue<CDmePresetGroup>( pCurrentGroup, "presetGroup" ) : NULL; if ( pPresetGroup && Q_stricmp( pPresetGroup->GetName(), pPresetGroupName ) ) { pPresetGroup = NULL; } KeyValues *kv = new KeyValues( "PresetNameSelected", "text", txt ); kv->SetString( "presetGroupName", pPresetGroupName ); SetElementKeyValue( kv, "presetGroup", pPresetGroup ); if ( m_pContextKeyValues ) { kv->AddSubKey( m_pContextKeyValues ); m_pContextKeyValues = NULL; } PostActionSignal( kv ); CloseModal(); return; } if ( !Q_stricmp( command, "Cancel") ) { CloseModal(); return; } BaseClass::OnCommand( command ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEditorSystem::DoSelect( CHL2WarsPlayer *pPlayer ) { #ifndef CLIENT_DLL // Sync from client return; #endif // CLIENT_DLL Vector vPos = pPlayer->Weapon_ShootPosition(); const Vector &vMouseAim = pPlayer->GetMouseAim(); const Vector &vCamOffset = pPlayer->GetCameraOffset(); Vector vStartPos, vEndPos; vStartPos = vPos + vCamOffset; vEndPos = vStartPos + (vMouseAim * MAX_TRACE_LENGTH); //NDebugOverlay::Line( vStartPos, vEndPos, 0, 255, 0, true, 4.0f ); Ray_t pickerRay; pickerRay.Init( vStartPos, vEndPos ); CWarsFlora *pBest = NULL; float fBestDistance = 0; #ifdef CLIENT_DLL for( CBaseEntity *pEntity = ClientEntityList().FirstBaseEntity(); pEntity; pEntity = ClientEntityList().NextBaseEntity( pEntity ) ) #else for( CBaseEntity *pEntity = gEntList.FirstEnt(); pEntity != NULL; pEntity = gEntList.NextEnt( pEntity ) ) #endif // CLIENT_DLL { CWarsFlora *pFlora = dynamic_cast<CWarsFlora *>( pEntity ); if( pFlora ) { // Prefer testing against hitboxes // If no hitboxes available, use the bounding box trace_t trace; bool bTestedHitBoxes = pFlora->TestHitboxes( pickerRay, MASK_SOLID, trace ); if( bTestedHitBoxes ) { if( trace.DidHit() ) { float fDistance = trace.endpos.DistTo( vStartPos ); if( !pBest || fDistance < fBestDistance ) { pBest = pFlora; fBestDistance = fDistance; } } } else { CBaseTrace trace2; if ( IntersectRayWithBox( pickerRay, pFlora->GetAbsOrigin() + pFlora->CollisionProp()->OBBMins(), pFlora->GetAbsOrigin() + pFlora->CollisionProp()->OBBMaxs(), 0.5f, &trace2 ) ) { float fDistance = trace2.endpos.DistTo( vStartPos ); if( !pBest || fDistance < fBestDistance ) { pBest = pFlora; fBestDistance = fDistance; } } } } } if( pBest ) { if( !IsSelected( pBest ) ) { Select( pBest ); KeyValues *pOperation = new KeyValues( "data" ); pOperation->SetString("operation", "select"); KeyValues *pFloraKey = new KeyValues( "flora", "uuid", pBest->GetFloraUUID() ); pFloraKey->SetBool( "select", true ); pOperation->AddSubKey( pFloraKey ); warseditorstorage->QueueServerCommand( pOperation ); } else { Deselect( pBest ); KeyValues *pOperation = new KeyValues( "data" ); pOperation->SetString("operation", "select"); KeyValues *pFloraKey = new KeyValues( "flora", "uuid", pBest->GetFloraUUID() ); pFloraKey->SetBool( "select", false ); pOperation->AddSubKey( pFloraKey ); warseditorstorage->QueueServerCommand( pOperation ); } //NDebugOverlay::Box( pBest->GetAbsOrigin(), -Vector(8, 8, 8), Vector(8, 8, 8), 0, 255, 0, 255, 5.0f); } }
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; }
static void saveZonFile(const char* szMapName) { KeyValues* zoneKV = new KeyValues(szMapName); CBaseEntity* pEnt = gEntList.FindEntityByClassname(NULL, "trigger_momentum_*"); while (pEnt) { KeyValues* subKey = NULL; if (pEnt->ClassMatches("trigger_momentum_timer_start")) { CTriggerTimerStart* pTrigger = dynamic_cast<CTriggerTimerStart*>(pEnt); subKey = new KeyValues("start"); if (pTrigger) { subKey->SetFloat("leavespeed", pTrigger->GetMaxLeaveSpeed()); subKey->SetBool("limitingspeed", pTrigger->IsLimitingSpeed()); } } else if (pEnt->ClassMatches("trigger_momentum_timer_stop")) { subKey = new KeyValues("end"); } else if (pEnt->ClassMatches("trigger_momentum_timer_checkpoint")) { CTriggerCheckpoint* pTrigger = dynamic_cast<CTriggerCheckpoint*>(pEnt); if (pTrigger) { subKey = new KeyValues("checkpoint"); subKey->SetInt("number", pTrigger->GetCheckpointNumber()); } } else if (pEnt->ClassMatches("trigger_momentum_onehop")) { CTriggerOnehop* pTrigger = dynamic_cast<CTriggerOnehop*>(pEnt); if (pTrigger) { subKey = new KeyValues("onehop"); //subKey->SetInt("destination", pTrigger->GetDestinationIndex()); subKey->SetBool("stop", pTrigger->ShouldStopPlayer()); subKey->SetBool("resetang", pTrigger->ShouldResetAngles()); subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime()); subKey->SetString("destinationname", pTrigger->m_target.ToCStr()); } } else if (pEnt->ClassMatches("trigger_momentum_resetonehop")) { subKey = new KeyValues("resetonehop"); } else if (pEnt->ClassMatches("trigger_momentum_teleport_checkpoint")) { CTriggerTeleportCheckpoint* pTrigger = dynamic_cast<CTriggerTeleportCheckpoint*>(pEnt); if (pTrigger) { subKey = new KeyValues("checkpoint_teleport"); //subKey->SetInt("destination", pTrigger->GetDestinationCheckpointNumber()); subKey->SetBool("stop", pTrigger->ShouldStopPlayer()); subKey->SetBool("resetang", pTrigger->ShouldResetAngles()); subKey->SetString("destinationname", pTrigger->m_target.ToCStr()); } } else if (pEnt->ClassMatches("trigger_momentum_multihop")) { CTriggerMultihop* pTrigger = dynamic_cast<CTriggerMultihop*>(pEnt); if (pTrigger) { subKey = new KeyValues("multihop"); //subKey->SetInt("destination", pTrigger->GetDestinationIndex()); subKey->SetBool("stop", pTrigger->ShouldStopPlayer()); subKey->SetFloat("hold", pTrigger->GetHoldTeleportTime()); subKey->SetBool("resetang", pTrigger->ShouldResetAngles()); subKey->SetString("destinationname", pTrigger->m_target.ToCStr()); } } else if (pEnt->ClassMatches("trigger_momentum_timer_stage")) { CTriggerStage *pTrigger = dynamic_cast<CTriggerStage*>(pEnt); if (pTrigger) { subKey = new KeyValues("stage"); subKey->SetInt("number", pTrigger->GetStageNumber()); } } if (subKey) { subKey->SetFloat("xPos", pEnt->GetAbsOrigin().x); subKey->SetFloat("yPos", pEnt->GetAbsOrigin().y); subKey->SetFloat("zPos", pEnt->GetAbsOrigin().z); subKey->SetFloat("xRot", pEnt->GetAbsAngles().x); subKey->SetFloat("yRot", pEnt->GetAbsAngles().y); subKey->SetFloat("zRot", pEnt->GetAbsAngles().z); subKey->SetFloat("xScaleMins", pEnt->WorldAlignMins().x); subKey->SetFloat("yScaleMins", pEnt->WorldAlignMins().y); subKey->SetFloat("zScaleMins", pEnt->WorldAlignMins().z); subKey->SetFloat("xScaleMaxs", pEnt->WorldAlignMaxs().x); subKey->SetFloat("yScaleMaxs", pEnt->WorldAlignMaxs().y); subKey->SetFloat("zScaleMaxs", pEnt->WorldAlignMaxs().z); zoneKV->AddSubKey(subKey); } pEnt = gEntList.FindEntityByClassname(pEnt, "trigger_momentum_*"); } if (zoneKV->GetFirstSubKey())//not empty { char zoneFilePath[MAX_PATH]; Q_strcpy(zoneFilePath, "maps/"); Q_strcat(zoneFilePath, szMapName, MAX_PATH); Q_strncat(zoneFilePath, ".zon", MAX_PATH); zoneKV->SaveToFile(filesystem, zoneFilePath, "MOD"); zoneKV->deleteThis(); } }
void CBaseGameStats_Driver::CollectData( StatSendType_t sendType ) { CGamestatsData *pGamestatsData = NULL; #ifdef GAME_DLL // for server, check with the engine to see if there already a gamestats data container registered. (There will be if there is a client // running in the same process.) pGamestatsData = engine->GetGamestatsData(); if ( pGamestatsData ) { // use the registered gamestats container, so free the one we allocated if ( m_pGamestatsData != NULL ) { delete m_pGamestatsData; m_pGamestatsData = NULL; } } else { pGamestatsData = m_pGamestatsData; } #else pGamestatsData = m_pGamestatsData; #endif Assert( pGamestatsData ); KeyValues *pKV = pGamestatsData->m_pKVData; int iAppID = engine->GetAppID(); pKV->SetInt( "appid", iAppID ); switch ( sendType ) { case STATSEND_LEVELSHUTDOWN: { // make a map node in the KeyValues to use for this level char szMap[MAX_PATH+1]=""; #ifdef CLIENT_DLL Q_FileBase( engine->GetLevelName(), szMap, ARRAYSIZE( szMap ) ); #else Q_strncpy( szMap, gpGlobals->mapname.ToCStr(), ARRAYSIZE( szMap ) ); #endif // CLIENT_DLL if ( !szMap[0] ) return; KeyValues *pKVMap = new KeyValues( "map" ); pKV->AddSubKey( pKVMap ); pKVMap->SetString( "mapname", szMap ); pKV = pKVMap; } break; case STATSEND_APPSHUTDOWN: break; default: Assert( false ); break; } // add common data pGamestatsData->m_bHaveData |= AddBaseDataForSend( pKV, sendType ); // add game-specific data pGamestatsData->m_bHaveData |= gamestats->AddDataForSend( pKV, sendType ); }
bool CASW_Mission_Chooser_Source_Local::ASW_Campaign_CreateNewSaveGame(char *szFileName, int iFileNameMaxLen, const char *szCampaignName, bool bMultiplayerGame, const char *szStartingMission) // szFileName arg is the desired filename or NULL for an autogenerated one. Function sets szFileName with the filename used. { if (!szFileName) return false; char stripped[MAX_PATH]; V_StripExtension( szCampaignName, stripped, MAX_PATH ); char szStartingMissionStripped[64]; if ( szStartingMission ) { V_StripExtension( szStartingMission, szStartingMissionStripped, sizeof( szStartingMissionStripped ) ); } else { szStartingMissionStripped[0] = 0; } // check the campaign file exists char campbuffer[MAX_PATH]; Q_snprintf(campbuffer, sizeof(campbuffer), "resource/campaigns/%s.txt", stripped); if (!g_pFullFileSystem->FileExists(campbuffer)) { Msg("No such campaign: %s\n", campbuffer); return false; } // Get the current time and date as a string char szDateTime[256]; int year, month, dayOfWeek, day, hour, minute, second; ASW_System_GetCurrentTimeAndDate(&year, &month, &dayOfWeek, &day, &hour, &minute, &second); Q_snprintf(szDateTime, sizeof(szDateTime), "%02d/%02d/%02d %02d:%02d", month, day, year, hour, minute); if (szFileName[0] == '\0') { // autogenerate a filename based on the current time and date Q_snprintf(szFileName, iFileNameMaxLen, "%s_save_%02d_%02d_%02d_%02d_%02d_%02d", stripped, year, month, day, hour, minute, second); } // make sure the path and extension are correct Q_SetExtension( szFileName, ".campaignsave", iFileNameMaxLen ); char tempbuffer[256]; Q_snprintf(tempbuffer, sizeof(tempbuffer), "%s", szFileName); const char *pszNoPathName = Q_UnqualifiedFileName(tempbuffer); Msg("Unqualified = %s\n", pszNoPathName); char szFullFileName[256]; Q_snprintf(szFullFileName, sizeof(szFullFileName), "save/%s", pszNoPathName); Msg("Creating new save with filename: %s\n", szFullFileName); KeyValues *pSaveKeyValues = new KeyValues( pszNoPathName ); int nMissionsComplete = 0; if ( szStartingMission && szStartingMission[0] ) { KeyValues *pCampaignDetails = GetCampaignDetails( stripped ); if ( pCampaignDetails ) { int nMissionSections = 0; for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() ) { if ( !Q_stricmp( pMission->GetName(), "MISSION" ) ) { if ( !Q_stricmp( pMission->GetString( "MapName", "" ), szStartingMissionStripped ) ) { nMissionsComplete = nMissionSections - 1; // skip first dummy mission break; } nMissionSections++; } } } } pSaveKeyValues->SetInt("Version", ASW_CURRENT_SAVE_VERSION); pSaveKeyValues->SetString("CampaignName", stripped); pSaveKeyValues->SetInt("CurrentPosition", nMissionsComplete + 1); // position squad on the first uncompleted mission pSaveKeyValues->SetInt("NumMissionsComplete", nMissionsComplete); pSaveKeyValues->SetInt("InitialNumMissionsComplete", nMissionsComplete); pSaveKeyValues->SetInt("Multiplayer", bMultiplayerGame ? 1 : 0); pSaveKeyValues->SetString("DateTime", szDateTime); pSaveKeyValues->SetInt("NumPlayers", 0); // write out each mission's status KeyValues *pSubSection; for (int i=0; i<ASW_MAX_MISSIONS_PER_CAMPAIGN; i++) { pSubSection = new KeyValues("MISSION"); pSubSection->SetInt("MissionID", i); bool bComplete = ( i != 0 ) && ( i <= nMissionsComplete ); pSubSection->SetInt("MissionComplete", bComplete ? 1 : 0 ); pSaveKeyValues->AddSubKey(pSubSection); } const int nInitialSkillPoints = 0; // write out each marine's stats for (int i=0; i<ASW_NUM_MARINE_PROFILES; i++) { pSubSection = new KeyValues("MARINE"); pSubSection->SetInt("MarineID", i); pSubSection->SetInt("SkillSlot0", 0); pSubSection->SetInt("SkillSlot1", 0); pSubSection->SetInt("SkillSlot2", 0); pSubSection->SetInt("SkillSlot3", 0); pSubSection->SetInt("SkillSlot4", 0); pSubSection->SetInt("SkillSlotSpare", nInitialSkillPoints + nMissionsComplete * ASW_SKILL_POINTS_PER_MISSION ); pSubSection->SetInt("UndoSkillSlot0", 0); pSubSection->SetInt("UndoSkillSlot1", 0); pSubSection->SetInt("UndoSkillSlot2", 0); pSubSection->SetInt("UndoSkillSlot3", 0); pSubSection->SetInt("UndoSkillSlot4", 0); pSubSection->SetInt("UndoSkillSlotSpare", nInitialSkillPoints + nMissionsComplete * ASW_SKILL_POINTS_PER_MISSION ); pSubSection->SetString("MissionsCompleted", ""); pSubSection->SetString("Medals", ""); pSubSection->SetInt("Wounded", 0); pSubSection->SetInt("Dead", 0); pSubSection->SetInt("ParasitesKilled", 0); pSaveKeyValues->AddSubKey(pSubSection); } // players section is empty at first // Create the save sub-directory if (!g_pFullFileSystem->IsDirectory( "save", "MOD" )) { g_pFullFileSystem->CreateDirHierarchy( "save", "MOD" ); } // save it if (pSaveKeyValues->SaveToFile(g_pFullFileSystem, szFullFileName)) { // make sure our save summary list adds this to it, if needed Msg("New save created: %s\n", szFullFileName); NotifyNewSave(pszNoPathName); return true; } Msg("Save to file failed. Filename=%s\n", szFullFileName); return false; }
//============================================================================= void GameSettings::OnCommand(const char *command) { if( V_strcmp( command, "cmd_gametype_campaign" ) == 0 ) { KeyValues *kvUpdate = new KeyValues( "update" ); kvUpdate->SetString( "game/mode", "campaign" ); KeyValues *kvModification = new KeyValues( "settings" ); kvModification->AddSubKey( kvUpdate ); UpdateSessionSettings( KeyValues::AutoDeleteInline( kvModification ) ); UpdateSelectMissionButton(); UpdateMissionImage(); } else if( V_strcmp( command, "cmd_gametype_single_mission" ) == 0 ) { KeyValues *kvUpdate = new KeyValues( "update" ); kvUpdate->SetString( "game/mode", "single_mission" ); KeyValues *kvModification = new KeyValues( "settings" ); kvModification->AddSubKey( kvUpdate ); UpdateSessionSettings( KeyValues::AutoDeleteInline( kvModification ) ); UpdateSelectMissionButton(); UpdateMissionImage(); } else if( V_strcmp( command, "cmd_gametype_sdk" ) == 0 ) { KeyValues *kvUpdate = new KeyValues( "update" ); kvUpdate->SetString( "game/mode", "sdk" ); KeyValues *kvModification = new KeyValues( "settings" ); kvModification->AddSubKey( kvUpdate ); UpdateSessionSettings( KeyValues::AutoDeleteInline( kvModification ) ); UpdateSelectMissionButton(); UpdateMissionImage(); } else if( V_strcmp( command, "cmd_gametype_swarmkeeper" ) == 0 ) { KeyValues *kvUpdate = new KeyValues( "update" ); kvUpdate->SetString( "game/mode", "swarmkeeper" ); KeyValues *kvModification = new KeyValues( "settings" ); kvModification->AddSubKey( kvUpdate ); UpdateSessionSettings( KeyValues::AutoDeleteInline( kvModification ) ); UpdateSelectMissionButton(); UpdateMissionImage(); } else if( V_strcmp( command, "cmd_change_mission" ) == 0 ) { ShowMissionSelect(); } else if ( V_strcmp( command, "cmd_change_starting_mission" ) == 0 ) { ShowStartingMissionSelect(); } else if ( char const *szMissionSelected = StringAfterPrefix( command, "cmd_mission_selected_" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " game { " " mission sdk_teams_hdr" " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); char stripped[MAX_PATH]; V_StripExtension( szMissionSelected, stripped, MAX_PATH ); pSettings->SetString( "update/game/mission", stripped ); UpdateSessionSettings( pSettings ); UpdateMissionImage(); } else if( char const *szLevelSelected = StringAfterPrefix( command, "cmd_level_selected_" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " game { " " mission sdk_teams_hdr " " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); char stripped[MAX_PATH]; V_StripExtension( szLevelSelected, stripped, MAX_PATH ); pSettings->SetString( "update/game/mission", szLevelSelected ); UpdateSessionSettings( pSettings ); UpdateMissionImage(); } else if( V_strcmp( command, "JoinAny" ) == 0 ) // Join game in progress { DoCustomMatch( "game" ); } else if( V_strcmp( command, "StartGame" ) == 0 ) { char const *szNetwork = m_pSettings->GetString( "system/network", "offline" ); if ( !Q_stricmp( szNetwork, "offline" ) ) { if ( IsCustomMatchSearchCriteria() ) { DoCustomMatch( "lobby" ); } else { Navigate(); } } else { // safety check if we aren't on live if( !CUIGameData::Get()->SignedInToLive() ) SelectNetworkAccess( "lan", "public" ); char const *szNetwork = m_pSettings->GetString( "system/network", "offline" ); char const *szAccess = m_pSettings->GetString( "system/access", "public" ); if ( !Q_stricmp( "LIVE", szNetwork ) && !Q_stricmp( "public", szAccess ) ) { if ( ui_game_allow_create_public.GetBool() ) { OnCommand( "Create" ); return; } // Instead of creating a new public lobby we're going to search // for any existing public lobbies that match these params! // This way people who take this path to a public lobby will still // be matched with humans (they might not end up a lobby leader). DoCustomMatch( "lobby" ); } else { Navigate(); } } } else if ( !Q_strcmp( command, "Create" ) ) { Assert( !IsEditingExistingLobby() ); g_pMatchFramework->CreateSession( m_pSettings ); } else if ( char const *szNetworkType = StringAfterPrefix( command, "GameNetwork_" ) ) { SelectNetworkAccess( szNetworkType, "public" ); } else if ( char const *szAccessType = StringAfterPrefix( command, "GameAccess_" ) ) { SelectNetworkAccess( "LIVE", szAccessType ); } // else if( V_strcmp( command, "StartLobby" ) == 0 ) // { // // } else if( V_strcmp( command, "Back" ) == 0 ) { // Act as though 360 back button was pressed OnKeyCodePressed( ButtonCodeToJoystickButtonCode( KEY_XBUTTON_B, CBaseModPanel::GetSingleton().GetLastActiveUserId() ) ); } else if ( const char *szDifficultyValue = StringAfterPrefix( command, "#L4D360UI_Difficulty_" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " game { " " difficulty = " " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetString( "update/game/difficulty", szDifficultyValue ); UpdateSessionSettings( pSettings ); if( m_drpDifficulty ) { if ( FlyoutMenu* pFlyout = m_drpDifficulty->GetCurrentFlyout() ) pFlyout->SetListener( this ); } } else if ( !Q_strcmp( command, "#L4D360UI_RegularFF" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " game { " " hardcoreFF = " " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetInt( "update/game/hardcoreFF", 0 ); UpdateSessionSettings( pSettings ); if( m_drpFriendlyFire ) { if ( FlyoutMenu* pFlyout = m_drpFriendlyFire->GetCurrentFlyout() ) pFlyout->SetListener( this ); } } else if ( !Q_strcmp( command, "#L4D360UI_HardcoreFF" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " game { " " hardcoreFF = " " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetInt( "update/game/hardcoreFF", 1 ); UpdateSessionSettings( pSettings ); if( m_drpFriendlyFire ) { if ( FlyoutMenu* pFlyout = m_drpFriendlyFire->GetCurrentFlyout() ) pFlyout->SetListener( this ); } } else if ( !Q_strcmp( command, "#L4D360UI_OnslaughtDisabled" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " game { " " onslaught = " " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetInt( "update/game/onslaught", 0 ); UpdateSessionSettings( pSettings ); if( m_drpOnslaught ) { if ( FlyoutMenu* pFlyout = m_drpOnslaught->GetCurrentFlyout() ) pFlyout->SetListener( this ); } } else if ( !Q_strcmp( command, "#L4D360UI_OnslaughtEnabled" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " game { " " onslaught = " " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetInt( "update/game/onslaught", 1 ); UpdateSessionSettings( pSettings ); if( m_drpOnslaught ) { if ( FlyoutMenu* pFlyout = m_drpOnslaught->GetCurrentFlyout() ) pFlyout->SetListener( this ); } } else if ( const char *szRoundLimitValue = StringAfterPrefix( command, "#L4D360UI_RoundLimit_" ) ) { KeyValues *pSettings = new KeyValues( "update" ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetInt( "update/game/maxrounds", atoi( szRoundLimitValue ) ); UpdateSessionSettings( pSettings ); } else if ( const char *szServerTypeValue = StringAfterPrefix( command, "#L4D360UI_ServerType_" ) ) { KeyValues *pSettings = KeyValues::FromString( "update", " update { " " options { " " server x " " } " " } " ); KeyValues::AutoDelete autodelete( pSettings ); char chBuffer[64]; Q_snprintf( chBuffer, sizeof( chBuffer ), "%s", szServerTypeValue ); for ( char *pszUpper = chBuffer; *pszUpper; ++ pszUpper ) { if ( isupper( *pszUpper ) ) *pszUpper = tolower( *pszUpper ); } pSettings->SetString( "update/options/server", chBuffer ); UpdateSessionSettings( pSettings ); if ( m_drpServerType ) { if ( FlyoutMenu *pFlyout = m_drpServerType->GetCurrentFlyout() ) pFlyout->SetListener( this ); } } else { BaseClass::OnCommand( command ); } }