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 } }
CASW_VGUI_Computer_Frame::CASW_VGUI_Computer_Frame( vgui::Panel *pParent, const char *pElementName, C_ASW_Hack_Computer* pHackComputer ) : vgui::Panel( pParent, pElementName ), CASW_VGUI_Ingame_Panel(), m_pHackComputer( pHackComputer ) { m_bHideLogoffButton = false; SetKeyBoardInputEnabled(true); m_fLastThinkTime = gpGlobals->curtime; m_pCurrentPanel = NULL; m_pMenuPanel = NULL; m_pSplash = NULL; m_bSetAlpha = false; m_pLogoffLabel = new ImageButton(this, "LogoffLabel", ""); m_pLogoffLabel->AddActionSignalTarget(this); KeyValues *msg = new KeyValues("Command"); msg->SetString("command", "Logoff"); m_pLogoffLabel->SetCommand(msg); KeyValues *cmsg = new KeyValues("Command"); cmsg->SetString( "command", "Cancel" ); m_pLogoffLabel->SetCancelCommand( cmsg ); m_pLogoffLabel->SetText("#asw_log_off"); for (int i=0;i<3;i++) { m_pScan[i] = new vgui::ImagePanel(this, "ComputerScan0"); m_pScan[i]->SetShouldScaleImage(true); m_pScan[i]->SetImage("swarm/Computer/ComputerScan"); } m_pBackdropImage = new vgui::ImagePanel(this, "SplashImage"); m_pBackdropImage->SetShouldScaleImage(true); m_iBackdropType = -1; SetBackdrop(0); RequestFocus(); m_bPlayingSplash = !IsPDA(); }
KeyValues *CNodeCustom::AllocateKeyValues( int NodeIndex ) { KeyValues *pKV = BaseClass::AllocateKeyValues( NodeIndex ); WriteJackDataFromKV( pKV, m_hszVarNames_In, m_hszVarNames_Out, GetNumJacks_In(), GetNumJacks_Out() ); pKV->SetString( "szFunctionName", m_szFunctionName ); pKV->SetString( "szFilePath", m_szFilePath ); pKV->SetInt( "iInline", m_bInline ? 1 : 0 ); CKVPacker::KVPack( m_pCode_Global, "szcode_global", pKV ); CKVPacker::KVPack( m_pCode_Function, "szcode_body", pKV ); //pKV->SetString( "szcode_global", m_pCode_Global ); //pKV->SetString( "szcode_body", m_pCode_Function ); pKV->SetInt( "iEnvFlags", m_iEnvFlags ); return pKV; }
//----------------------------------------------------------------------------- // Purpose: Sets a custom string list //----------------------------------------------------------------------------- void CVarListPropertyPage::SetCustomStringList(const char *varName, const char *stringList) { // find the item by name int itemID = m_pRulesList->GetItem(varName); KeyValues *rule = m_pRulesList->GetItem(itemID); if (!rule) return; rule->SetString("stringlist", stringList); }
void FinishClientPutInServer( CHL2MP_Player *pPlayer ) { pPlayer->InitialSpawn(); //BB: we dont want players to spawn immediately when joining the server, we want them to auto spectate //pPlayer->Spawn(); pPlayer->ChangeTeam( TEAM_SPECTATOR ); char sName[128]; Q_strncpy( sName, pPlayer->GetPlayerName(), sizeof( sName ) ); // First parse the name and remove any %'s for ( char *pApersand = sName; pApersand != NULL && *pApersand != 0; pApersand++ ) { // Replace it with a space if ( *pApersand == '%' ) *pApersand = ' '; } // notify other clients of player joining the game UTIL_ClientPrintAll( HUD_PRINTNOTIFY, "#Game_connected", sName[0] != 0 ? sName : "<unconnected>" ); if ( HL2MPRules()->IsTeamplay() == true ) { ClientPrint( pPlayer, HUD_PRINTTALK, "You are on team %s1\n", pPlayer->GetTeam()->GetName() ); } const ConVar *hostname = cvar->FindVar( "hostname" ); const char *title = (hostname) ? hostname->GetString() : "MESSAGE OF THE DAY"; KeyValues *data = new KeyValues("data"); data->SetString( "title", title ); // info panel title data->SetString( "type", "1" ); // show userdata from stringtable entry data->SetString( "msg", "motd" ); // use this stringtable entry data->SetBool( "unload", sv_motd_unload_on_dismissal.GetBool() ); //BB: Display the team selection panel... pPlayer->ShowViewPortPanel( PANEL_TEAM, true, data ); pPlayer->ShowViewPortPanel( PANEL_INFO, true, data ); data->deleteThis(); }
KeyValues* VMFExporter::GetPlayerStarts() { KeyValues *pKeys = new KeyValues( "entity" ); pKeys->SetInt( "id", m_iEntityCount++ ); pKeys->SetString( "classname", "info_player_start" ); pKeys->SetString( "angles", "0 0 0" ); // put a single player start in the centre of the player start tile selected float player_start_x = 128.0f; float player_start_y = 128.0f; int half_map_size = MAP_LAYOUT_TILES_WIDE * 0.5f; player_start_x += (m_pMapLayout->m_iPlayerStartTileX - half_map_size) * ASW_TILE_SIZE; player_start_y += (m_pMapLayout->m_iPlayerStartTileY - half_map_size) * ASW_TILE_SIZE; char buffer[128]; Q_snprintf(buffer, sizeof(buffer), "%f %f 1.0", player_start_x, player_start_y); pKeys->SetString( "origin", buffer ); return pKeys; }
//----------------------------------------------------------------------------- // 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 ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CStunEffect::Init( void ) { m_flDuration = 0.0f; m_flFinishTime = 0.0f; m_bUpdateView = true; KeyValues *pVMTKeyValues = new KeyValues( "UnlitGeneric" ); pVMTKeyValues->SetString( "$basetexture", STUN_TEXTURE ); m_EffectMaterial.Init( "__stuneffect", TEXTURE_GROUP_CLIENT_EFFECTS, pVMTKeyValues ); m_StunTexture.Init( STUN_TEXTURE, TEXTURE_GROUP_CLIENT_EFFECTS ); }
bool CLevelTheme::SaveTheme(const char *pszThemeName) { char szFullFileName[MAX_PATH]; Q_snprintf(szFullFileName, sizeof(szFullFileName), "tilegen/themes/%s.theme", pszThemeName); KeyValues *pThemeKeyValues = new KeyValues( pszThemeName ); pThemeKeyValues->SetString("ThemeName", m_szName); pThemeKeyValues->SetString("ThemeDescription", m_szDescription); pThemeKeyValues->SetBool( "VMFTweak", m_bRequiresVMFTweak ); pThemeKeyValues->SetBool( "SkipErrorCheck", m_bSkipErrorCheck ); char buffer[128]; Q_snprintf( buffer, sizeof( buffer ), "%f %f %f", m_vecAmbientLight.x, m_vecAmbientLight.y, m_vecAmbientLight.z ); pThemeKeyValues->SetString( "AmbientLight", buffer ); if (!pThemeKeyValues->SaveToFile(g_pFullFileSystem, szFullFileName, "GAME")) { Msg("Error: Failed to save theme %s\n", szFullFileName); return false; } // TODO: check the room templates folder for this theme exists return true; }
//----------------------------------------------------------------------------- // Shared code //----------------------------------------------------------------------------- static inline void RecordWorldDecal( const Vector *pos, int index ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_WORLD_DECAL ); msg->SetString( "name", "TE_WorldDecal" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", pos->x ); msg->SetFloat( "originy", pos->y ); msg->SetFloat( "originz", pos->z ); msg->SetString( "decalname", effects->Draw_DecalNameFromIndex( index ) ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void MountExtraContent() { memset(g_AppStatus, 0, sizeof(g_AppStatus)); KeyValues *pMountList = new KeyValues( "MountList" ); if( !pMountList->LoadFromFile( filesystem, "mountlist.txt" ) ) { // Create default pMountList->SetString( "dota", "0" ); pMountList->SetString( "left4dead", "0" ); pMountList->SetString( "left4dead2", "0" ); pMountList->SetString( "portal2", "0" ); pMountList->SetString( "csgo", "0" ); pMountList->SetString( "dearesther", "0" ); pMountList->SaveToFile( filesystem, "mountlist.txt", "MOD" ); } if( TryMountVPKGame( "DOTA", "../../common/dota 2 beta/dota", APP_DOTA, "dota", pMountList ) ) PostProcessDota2( "models" ); TryMountVPKGame( "Portal 2", "../../common/portal 2/portal2", APP_PORTAL2, "portal2", pMountList ); TryMountVPKGame( "Left 4 Dead 2", "../../common/left 4 dead 2/left4dead2", APP_L4D2, "left4dead2", pMountList ); TryMountVPKGame( "Left 4 Dead", "../../common/left 4 dead/left4dead", APP_L4D1, "left4dead", pMountList ); TryMountVPKGame( "Counter-Strike Global Offensive", "../../common/Counter-Strike Global Offensive/csgo", APP_CSGO, "csgo", pMountList ); TryMountVPKGame( "Dear Esther", "../../common/dear esther/dearesther", APP_DEARESTHER, "dearesther", pMountList ); if( pMountList ) { pMountList->deleteThis(); pMountList = NULL; } }
//----------------------------------------------------------------------------- // Purpose: expands a path //----------------------------------------------------------------------------- void DirectorySelectDialog::ExpandTreeNode(const char *path, int parentNodeIndex) { // set the small wait cursor surface()->SetCursor(dc_waitarrow); // get all the subfolders of the current drive char searchString[512]; sprintf(searchString, "%s*.*", path); //Updated to use IFileSystem instead of OS file enumeration functions. - Solokiller //Also includes better directory detection for special directories. FileFindHandle_t h; const char *pFileName = filesystem()->FindFirst( searchString, &h ); for( ; pFileName; pFileName = filesystem()->FindNext( h ) ) { if( !Q_stricmp( pFileName, ".." ) || !Q_stricmp( pFileName, "." ) ) continue; KeyValues *kv = new KeyValues( "item" ); kv->SetString( "Text", pFileName ); // set the folder image kv->SetInt( "Image", 1 ); kv->SetInt( "SelectedImage", 1 ); kv->SetInt( "Expand", DoesDirectoryHaveSubdirectories( path, pFileName ) ); m_pDirTree->AddItem( kv, parentNodeIndex ); } filesystem()->FindClose( h ); //Old code: /* _finddata_t wfd; memset(&wfd, 0, sizeof(_finddata_t)); long hResult = _findfirst(searchString, &wfd); if (hResult != -1) { do { if ((wfd.attrib & _A_SUBDIR) && wfd.name[0] != '.') { KeyValues *kv = new KeyValues("item"); kv->SetString("Text", wfd.name); // set the folder image kv->SetInt("Image", 1); kv->SetInt("SelectedImage", 1); kv->SetInt("Expand", DoesDirectoryHaveSubdirectories(path, wfd.name)); m_pDirTree->AddItem(kv, parentNodeIndex); } } while (_findnext(hResult, &wfd) == 0); _findclose(hResult); } */ }
void CShaderPrecache::SaveList() { KeyValues *pKV = new KeyValues( "shaderlist" ); for ( int i = 0; i < m_pPanelList.Count(); i++ ) { char name[MAX_PATH]; m_pPanelList[i].L->GetText( name, MAX_PATH ); pKV->SetString( VarArgs( "shader_%03i", i ), name ); } df_SaveDump_List( pKV ); }
CASW_VGUI_Computer_Menu::CASW_VGUI_Computer_Menu( vgui::Panel *pParent, const char *pElementName, C_ASW_Hack_Computer* pHackComputer ) : vgui::Panel( pParent, pElementName ), CASW_VGUI_Ingame_Panel(), m_pHackComputer( pHackComputer ) { for (int i=0;i<ASW_COMPUTER_MAX_MENU_ITEMS;i++) { m_pMenuLabel[i] = new ImageButton(this, "ComputerMenuLabel", ""); m_pMenuLabel[i]->AddActionSignalTarget(this); KeyValues *msg = new KeyValues("Command"); char buffer[16]; Q_snprintf(buffer, sizeof(buffer), "Option%d", i); msg->SetString("command", buffer); m_pMenuLabel[i]->SetCommand(msg); KeyValues *cmsg = new KeyValues("Command"); cmsg->SetString( "command", "Cancel" ); m_pMenuLabel[i]->SetCancelCommand( cmsg ); m_pMenuIcon[i] = new vgui::ImagePanel(this, "ComputerMenuIcon"); m_pMenuIconShadow[i] = new vgui::ImagePanel(this, "ComputerMenuIconShadow"); } m_pBlackBar[0] = new vgui::ImagePanel(this, "ComputerMenuBar1"); m_pBlackBar[1] = new vgui::ImagePanel(this, "ComputerMenuBar2"); m_hCurrentPage = NULL; m_bFadingCurrentPage = false; m_iPrepareHackOption = -1; m_iMouseOverOption = -1; m_iOldMouseOverOption = -1; m_iPreviousHackOption = 0; m_bSetAlpha = false; m_iAutodownload = -1; m_pAccessDeniedLabel = new vgui::Label(this, "AccessDeniedLabel", "#asw_computer_access_denied"); m_pAccessDeniedLabel->SetContentAlignment(vgui::Label::a_center); m_pInsufficientRightsLabel = new vgui::Label(this, "AccessDeniedLabel", "#asw_computer_insufficient_rights"); }
//--------------------------------------------------------------------- // Purpose: Send all properties and contexts to the matchmaking session //--------------------------------------------------------------------- void CSessionOptionsDialog::SetupSession( void ) { KeyValues *pKeys = new KeyValues( "SessionKeys" ); // Send user-selected properties and contexts for ( int i = 0; i < m_Menu.GetItemCount(); ++i ) { COptionsItem *pItem = dynamic_cast< COptionsItem* >( m_Menu.GetItem( i ) ); if ( !pItem ) { continue; } const sessionProperty_t &prop = pItem->GetActiveOption(); KeyValues *pProperty = pKeys->CreateNewKey(); pProperty->SetName( prop.szID ); pProperty->SetInt( "type", prop.nType ); pProperty->SetString( "valuestring", prop.szValue ); pProperty->SetString( "valuetype", prop.szValueType ); pProperty->SetInt( "optionindex", pItem->GetActiveOptionIndex() ); } // Send contexts and properties parsed from the resource file for ( int i = 0; i < m_SessionProperties.Count(); ++i ) { const sessionProperty_t &prop = m_SessionProperties[i]; KeyValues *pProperty = pKeys->CreateNewKey(); pProperty->SetName( prop.szID ); pProperty->SetInt( "type", prop.nType ); pProperty->SetString( "valuestring", prop.szValue ); pProperty->SetString( "valuetype", prop.szValueType ); } // Matchmaking will make a copy of these keys matchmaking->SetSessionProperties( pKeys ); pKeys->deleteThis(); }
KeyValues* VMFExporter::GetGameRulesProxy() { KeyValues *pKeys = new KeyValues( "entity" ); pKeys->SetInt( "id", m_iEntityCount++ ); pKeys->SetString( "classname", "asw_gamerules" ); pKeys->SetString( "targetname", "@asw_gamerules" ); char buffer[128]; Q_snprintf(buffer, sizeof(buffer), "%f %f %f", m_vecStartRoomOrigin.x, m_vecStartRoomOrigin.y, m_vecStartRoomOrigin.z); pKeys->SetString( "origin", buffer ); KeyValues *pGenerationOptions = m_pMapLayout->GetGenerationOptions(); int nDifficultyModifier = 0; if ( pGenerationOptions != NULL ) { nDifficultyModifier = pGenerationOptions->GetInt( "Difficulty", 5 ) - 5; } pKeys->SetInt( "difficultymodifier", nDifficultyModifier ); return pKeys; }
//----------------------------------------------------------------------------- // Add a file to the file list. //----------------------------------------------------------------------------- int PerforceFileList::AddFileToFileList( const char *pFullPath, bool bExistsOnDisk ) { bool bIsFileWriteable = bExistsOnDisk ? g_pFullFileSystem->IsFileWritable( pFullPath, NULL ) : true; // add the file to the list KeyValues *kv = new KeyValues("item"); const char *pRelativePath = Q_UnqualifiedFileName( pFullPath ); kv->SetString( "text", pRelativePath ); kv->SetString( "fullpath", pFullPath ); kv->SetInt( "image", 1 ); IImage *pImage = surface()->GetIconImageForFullPath( pFullPath ); if ( pImage ) { kv->SetPtr( "iconImage", (void *)pImage ); } kv->SetInt( "imageSelected", 1 ); kv->SetInt( "directory", 0 ); // These are computed by Refresh kv->SetInt( "in_perforce", 0 ); kv->SetInt( "synched", 0 ); kv->SetInt( "checked_out", 0 ); kv->SetInt( "deleted", 0 ); wchar_t pFileType[ 80 ]; g_pFullFileSystem->GetFileTypeForFullPath( pFullPath, pFileType, sizeof( pFileType ) ); kv->SetWString( "type", pFileType ); kv->SetString( "attributes", bIsFileWriteable ? "" : "R" ); int nItemID = AddItem( kv, 0, false, false ); kv->deleteThis(); AddItemToDirectoryList( pFullPath, nItemID, false ); return nItemID; }
//----------------------------------------------------------------------------- // Purpose: Remove all instances of the specified key from bindings //----------------------------------------------------------------------------- void COptionsSubKeyboard::RemoveKeyFromBindItems( KeyValues *org_item, const char *key ) { Assert( key && key[ 0 ] ); if ( !key || !key[ 0 ] ) return; int len = Q_strlen( key ); char *pszKey = new char[len + 1]; if ( !pszKey ) return; Q_memcpy( pszKey, key, len+1 ); for (int i = 0; i < m_pKeyBindList->GetItemCount(); i++) { KeyValues *item = m_pKeyBindList->GetItemData(m_pKeyBindList->GetItemIDFromRow(i)); if ( !item ) continue; // If it's bound to the primary: then remove it if ( !stricmp( pszKey, item->GetString( "Key", "" ) ) ) { bool bClearEntry = true; if ( org_item ) { // Only clear it out if the actual binding isn't the same. This allows // us to have the same key bound to multiple entries in the keybinding list // if they point to the same command. const char *org_binding = org_item->GetString( "Binding", "" ); const char *binding = item->GetString( "Binding", "" ); if ( !stricmp( org_binding, binding ) ) { bClearEntry = false; } } if ( bClearEntry ) { item->SetString( "Key", "" ); m_pKeyBindList->InvalidateItem(i); } } } delete [] pszKey; // Make sure the display is up to date m_pKeyBindList->InvalidateLayout(); }
//----------------------------------------------------------------------------- // Recording //----------------------------------------------------------------------------- static inline void RecordBreakModel( const Vector &start, const QAngle &angles, const Vector &size, const Vector &vel, int nModelIndex, int nRandomization, int nCount, float flDuration, int nFlags ) { if ( !ToolsEnabled() ) return; if ( clienttools->IsInRecordingMode() ) { const model_t* pModel = (nModelIndex != 0) ? modelinfo->GetModel( nModelIndex ) : NULL; const char *pModelName = pModel ? modelinfo->GetModelName( pModel ) : ""; KeyValues *msg = new KeyValues( "TempEntity" ); msg->SetInt( "te", TE_BREAK_MODEL ); msg->SetString( "name", "TE_BreakModel" ); msg->SetFloat( "time", gpGlobals->curtime ); msg->SetFloat( "originx", start.x ); msg->SetFloat( "originy", start.y ); msg->SetFloat( "originz", start.z ); msg->SetFloat( "anglesx", angles.x ); msg->SetFloat( "anglesy", angles.y ); msg->SetFloat( "anglesz", angles.z ); msg->SetFloat( "sizex", size.x ); msg->SetFloat( "sizey", size.y ); msg->SetFloat( "sizez", size.z ); msg->SetFloat( "velx", vel.x ); msg->SetFloat( "vely", vel.y ); msg->SetFloat( "velz", vel.z ); msg->SetString( "model", pModelName ); msg->SetInt( "randomization", nRandomization ); msg->SetInt( "count", nCount ); msg->SetFloat( "duration", flDuration ); msg->SetInt( "flags", nFlags ); ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg ); msg->deleteThis(); } }
//----------------------------------------------------------------------------- // Purpose: on individual player added //----------------------------------------------------------------------------- void CDialogMapInfo::AddPlayerToList(const char *playerName, int score, float timePlayedSeconds) { if (m_bPlayerListUpdatePending) { m_bPlayerListUpdatePending = false; m_pPlayerList->RemoveAll(); } KeyValues *player = new KeyValues("player"); player->SetString("PlayerName", playerName); player->SetInt("Score", score); player->SetInt("TimeSec", (int) timePlayedSeconds); // construct a time string int seconds = (int) timePlayedSeconds; int minutes = seconds / 60; int hours = minutes / 60; seconds %= 60; minutes %= 60; char buf[64]; buf[0] = 0; if (hours) { Q_snprintf(buf, sizeof(buf), "%dh %dm %ds", hours, minutes, seconds); } else if (minutes) { Q_snprintf(buf, sizeof(buf), "%dm %ds", minutes, seconds); } else { Q_snprintf(buf, sizeof(buf), "%ds", seconds); } player->SetString("Time", buf); m_pPlayerList->AddItem(player, 0, false, true); player->deleteThis(); }
/* int iEnvC_ID; int iHLSLRegister; */ KeyValues *__AllocKV_Combo( int i, SimpleCombo *c ) { char tmp[MAX_PATH]; Q_snprintf( tmp, MAX_PATH, "combo_%i", i ); KeyValues *pKV = new KeyValues( tmp ); pKV->SetString( "sz_name", c->name ); pKV->SetInt( "i_static", c->bStatic ? 1 : 0 ); pKV->SetInt( "i_min", c->min ); pKV->SetInt( "i_max", c->max ); pKV->SetInt( "i_type", c->iComboType ); return pKV; }
void CInstanceSpawn::SaveToKeyValues( KeyValues *pKeyValues ) const { pKeyValues->SetString( "filename", m_InstanceFilename ); switch ( m_InstanceSpawningMethod ) { case ISM_ADD_AT_RANDOM_NODE: pKeyValues->SetString( "type", "add_at_random_node" ); break; default: Log_Warning( LOG_TilegenLayoutSystem, "Invalid instance spawning method (%d).\n", m_InstanceSpawningMethod ); } pKeyValues->SetInt( "room_index", m_nPlacedRoomIndex ); pKeyValues->SetInt( "random_seed", m_nRandomSeed ); for ( int i = 0; i < m_AdditionalKeyValues.Count(); ++ i ) { KeyValues *pNewReplacement = new KeyValues( "key_value" ); pNewReplacement->SetString( "key", m_AdditionalKeyValues[i].m_Key ); pNewReplacement->SetString( "value", m_AdditionalKeyValues[i].m_Value ); pKeyValues->AddSubKey( pNewReplacement ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void AnimationController::RunCmd_SetString( PostedMessage_t &msg ) { Panel *panel = FindSiblingByName(g_ScriptSymbols.String(msg.event)); Assert(panel != NULL); if (!panel) return; KeyValues *inputData = new KeyValues(g_ScriptSymbols.String(msg.variable)); inputData->SetString(g_ScriptSymbols.String(msg.variable), g_ScriptSymbols.String(msg.variable2)); if (!panel->SetInfo(inputData)) { // Assert(!("Unhandlable var in AnimationController::SetValue())")); } inputData->deleteThis(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CGameUI::SetProgressLevelName( const char *levelName ) { MEM_ALLOC_CREDIT(); if ( g_hLoadingBackgroundDialog ) { KeyValues *pKV = new KeyValues( "ProgressLevelName" ); pKV->SetString( "levelName", levelName ); vgui::ivgui()->PostMessage( g_hLoadingBackgroundDialog, pKV, NULL ); } if ( g_hLoadingDialog.Get() ) { // TODO: g_hLoadingDialog->SetLevelName( levelName ); } }
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; }
// loop through all the maps checking filters FOR_EACH_VEC(m_vecMaps, i) { mapdisplay_t &map = m_vecMaps[i]; mapstruct_t* mapinfo = &map.m_mMap; //DevLog("CURRENTLY FILTERING %s\n", mapinfo->m_szMapName); if (!CheckPrimaryFilters(*mapinfo) || !CheckSecondaryFilters(*mapinfo))//MOM_TODO: change this to just one filter check? { //Failed filters, remove the map map.m_bDoNotRefresh = true; if (m_pGameList->IsValidItemID(map.m_iListID)) { m_pGameList->SetItemVisible(map.m_iListID, false); } } else if (BShowMap(map)) { map.m_bDoNotRefresh = false; if (!m_pGameList->IsValidItemID(map.m_iListID)) { //DevLog("ADDING MAP TO LIST! %s\n ", mapinfo->m_szMapName); KeyValues *kv = new KeyValues("Map"); kv->SetString("name", mapinfo->m_szMapName); kv->SetString("map", mapinfo->m_szMapName); kv->SetInt("gamemode", mapinfo->m_iGameMode); kv->SetInt("difficulty", mapinfo->m_iDifficulty); kv->SetInt("MapLayout", ((int)mapinfo->m_bHasStages) + 2);//+ 2 so the picture sets correctly kv->SetBool("HasCompleted", mapinfo->m_bCompleted); kv->SetString("time", mapinfo->m_szBestTime); map.m_iListID = m_pGameList->AddItem(kv, NULL, false, false); kv->deleteThis(); } // make sure the map is visible m_pGameList->SetItemVisible(map.m_iListID, true); } }
void CFileListManager::OnMousePressed( vgui::MouseCode code ) { // determine where we were pressed int x, y, row, column; vgui::input()->GetCursorPos( x, y ); GetCellAtPos( x, y, row, column ); if ( code == MOUSE_LEFT ) { bool bIsFakeToggleButton = column == CI_LOADED; if ( bIsFakeToggleButton && row >= 0 && row < GetItemCount() ) { int itemID = GetItemIDFromRow( row ); KeyValues *kv = GetItem( itemID ); const char *pStr = kv->GetString( GetKey( ( ColumnIndex_t )column ), "" ); Assert( *pStr == 'Y' || *pStr == 'N' ); bool bSet = *pStr == 'N'; // bSet is the NEW state, not the old one kv->SetString( GetKey( ( ColumnIndex_t )column ), bSet ? "Y" : "N" ); SetLoaded( ( DmFileId_t )GetItemUserData( itemID ), bSet ); // get the key focus RequestFocus(); return; } } else if ( code == MOUSE_RIGHT ) { int itemID = -1; if ( row >= 0 && row < GetItemCount() ) { itemID = GetItemIDFromRow( row ); if ( !IsItemSelected( itemID ) ) { SetSingleSelectedItem( itemID ); } } KeyValues *kv = new KeyValues( "OpenContextMenu", "itemID", itemID ); OnOpenContextMenu( kv ); kv->deleteThis(); return; } BaseClass::OnMousePressed( code ); }
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 ); } }
//----------------------------------------------------------------------------- // Purpose: Remove all keys from list //----------------------------------------------------------------------------- void COptionsSubKeyboard::ClearBindItems( void ) { for (int i = 0; i < m_pKeyBindList->GetItemCount(); i++) { KeyValues *item = m_pKeyBindList->GetItemData(m_pKeyBindList->GetItemIDFromRow(i)); if ( !item ) continue; // Reset keys item->SetString( "Key", "" ); m_pKeyBindList->InvalidateItem(i); } m_pKeyBindList->InvalidateLayout(); }
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; }