Ejemplo n.º 1
0
void CMapListPanel::OnMouseReleased(MouseCode code)
{
    if (code == MOUSE_LEFT)
    {
        int x, y;
        input()->GetCursorPosition(x, y);
        int row, col;
        if (GetCellAtPos(x, y, row, col))
        {
            int itemID = GetItemIDFromRow(row);
            uint32 mapID = GetItemUserData(itemID);
            KeyValues *pMap = GetItem(itemID);
            if (pMap)
            {
                if (col == HEADER_MAP_IN_LIBRARY)
                {
                    if (pMap->GetInt(KEYNAME_MAP_IN_LIBRARY) == INDX_MAP_IN_LIBRARY)
                        MapSelectorDialog().OnRemoveMapFromLibrary(mapID);
                    else
                        MapSelectorDialog().OnAddMapToLibrary(mapID);
                }
                else if (col == HEADER_MAP_IN_FAVORITES)
                {
                    if (pMap->GetInt(KEYNAME_MAP_IN_FAVORITES) == INDX_MAP_IN_FAVORITES)
                        MapSelectorDialog().OnRemoveMapFromFavorites(mapID);
                    else
                        MapSelectorDialog().OnAddMapToFavorites(mapID);
                }
            }
        }
    }
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// Purpose: loads filter settings (from disk) from the keyvalues
//-----------------------------------------------------------------------------
void CBaseMapsPage::LoadFilterSettings()
{
    KeyValues *filter = MapSelectorDialog().GetFilterSaveData(GetName());

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

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

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

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

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

    // apply to the controls
    OnLoadFilter(filter);
    UpdateFilterSettings();
    ApplyGameFilters();
}
Ejemplo n.º 3
0
// fills in the target list panel with buttons for each of the entries in the desired list
bool SwarmopediaTopics::SetupList(SwarmopediaPanel *pPanel, const char *szDesiredList)
{
	// look through our KeyValues for the desired list
	KeyValues *pkvList = GetSubkeyForList(szDesiredList);
	if (!pkvList)
	{
		Msg("Swarmopedia error: Couldn't find list %s\n", szDesiredList);
		return false;
	}

	// now go through every LISTENTRY in the subkey we found, adding it to the list panel
	int iPlayerUnlockLevel = 999;	// todo: have this check a convar that measures how far through the jacob campaign the player has got
	while ( pkvList )
	{
		if (Q_stricmp(pkvList->GetName(), "LISTENTRY")==0)
		{
			const char *szEntryName = pkvList->GetString("Name");
			const char *szArticleTarget = pkvList->GetString("ArticleTarget");
			const char *szListTarget = pkvList->GetString("ListTarget");
			int iEntryUnlockLevel = pkvList->GetInt("UnlockLevel");
			int iSectionHeader = pkvList->GetInt("SectionHeader");

			if (iEntryUnlockLevel == 0 || iEntryUnlockLevel < iPlayerUnlockLevel)
			{
				pPanel->AddListEntry(szEntryName, szArticleTarget, szListTarget, iSectionHeader);
			}
		}
		pkvList = pkvList->GetNextKey();
	}
	return true;
}
Ejemplo n.º 4
0
void ReadKVIdents_Combos( CUtlVector< SimpleCombo* > &hList, KeyValues *pKV )
{
	int itr = 0;
	char tmp[MAX_PATH];
	Q_snprintf( tmp, MAX_PATH, "combo_%i", itr );
	KeyValues *c = pKV->FindKey( tmp );

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

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

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

		hList.AddToTail( combo );
		itr++;
		Q_snprintf( tmp, MAX_PATH, "combo_%i", itr );
		c = pKV->FindKey( tmp );
	}
}
Ejemplo n.º 5
0
void ReadKVIdents_Texture( CUtlVector< SimpleTexture* > &hList, KeyValues *pKV )
{
	int itr = 0;
	char tmp[MAX_PATH];
	Q_snprintf( tmp, MAX_PATH, "texsamp_%i", itr );
	KeyValues *c = pKV->FindKey( tmp );

	while( c )
	{
		SimpleTexture *tex = new SimpleTexture();

		const char *paramname = c->GetString( "sz_param" );
		int len = Q_strlen( paramname ) + 1;
		tex->szParamName = new char[ len ];
		Q_snprintf( tex->szParamName, MAX_PATH, "%s", paramname );

		const char *fallbackname = c->GetString( "sz_fallback" );
		len = Q_strlen( fallbackname ) + 1;
		tex->szFallbackName = new char[ len ];
		Q_snprintf( tex->szFallbackName, MAX_PATH, "%s", fallbackname );

		tex->iSamplerIndex = c->GetInt( "i_sampidx" );
		tex->iTextureMode = c->GetInt( "i_texmode" );
		tex->bCubeTexture = !!c->GetInt( "i_cubemap" );
		tex->bSRGB = !!c->GetInt( "i_srgb" );

		hList.AddToTail( tex );
		itr++;
		Q_snprintf( tmp, MAX_PATH, "texsamp_%i", itr );
		c = pKV->FindKey( tmp );
	}
}
Ejemplo n.º 6
0
void CRoomTemplate::LoadFromKeyValues( const char *pRoomName, KeyValues *pKeyValues )
{
    m_nTilesX = pKeyValues->GetInt( "TilesX", 1 );
    m_nTilesY = pKeyValues->GetInt( "TilesY", 1 );
    SetSpawnWeight( pKeyValues->GetInt( "SpawnWeight", MIN_SPAWN_WEIGHT ) );

    SetFullName( pRoomName );

    Q_strncpy( m_Description, pKeyValues->GetString( "RoomTemplateDescription", "" ), m_nMaxDescriptionLength );
    Q_strncpy( m_Soundscape, pKeyValues->GetString( "Soundscape", "" ), m_nMaxSoundscapeLength );

    SetTileType( pKeyValues->GetInt( "TileType", ASW_TILETYPE_UNKNOWN ) );

    m_Tags.RemoveAll();

    // search through all the exit subsections
    KeyValues *pkvSubSection = pKeyValues->GetFirstSubKey();
    bool bClearedExits = false;
    while ( pkvSubSection )
    {
        // mission details
        if ( Q_stricmp(pkvSubSection->GetName(), "EXIT")==0 )
        {
            if ( !bClearedExits )
            {
                // if we haven't cleared previous exits yet then do so now
                m_Exits.PurgeAndDeleteElements();
                bClearedExits = true;
            }
            CRoomTemplateExit *pExit = new CRoomTemplateExit();
            pExit->m_iXPos = pkvSubSection->GetInt("XPos");
            pExit->m_iYPos = pkvSubSection->GetInt("YPos");
            pExit->m_ExitDirection = (ExitDirection_t) pkvSubSection->GetInt("ExitDirection");
            pExit->m_iZChange = pkvSubSection->GetInt("ZChange");
            Q_strncpy( pExit->m_szExitTag, pkvSubSection->GetString( "ExitTag" ), sizeof( pExit->m_szExitTag ) );
            pExit->m_bChokepointGrowSource = !!pkvSubSection->GetInt("ChokeGrow", 0);

            // discard exits outside the room bounds
            if ( pExit->m_iXPos < 0 || pExit->m_iYPos < 0 || pExit->m_iXPos >= m_nTilesX || pExit->m_iYPos >= m_nTilesY )
            {
                delete pExit;
            }
            else
            {
                m_Exits.AddToTail(pExit);
            }
        }
        else if ( Q_stricmp(pkvSubSection->GetName(), "Tags")==0 && TagList() )
        {
            for ( KeyValues *sub = pkvSubSection->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
            {
                if ( !Q_stricmp( sub->GetName(), "tag" ) )
                {
                    AddTag( sub->GetString() );
                }
            }
        }
        pkvSubSection = pkvSubSection->GetNextKey();
    }
}
Ejemplo n.º 7
0
void ReadKVIdents_EConst( CUtlVector< SimpleEnvConstant* > &hList, KeyValues *pKV )
{
	int itr = 0;
	char tmp[MAX_PATH];
	Q_snprintf( tmp, MAX_PATH, "econst_%i", itr );
	KeyValues *c = pKV->FindKey( tmp );

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

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

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

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

		hList.AddToTail( econst );
		itr++;
		Q_snprintf( tmp, MAX_PATH, "econst_%i", itr );
		c = pKV->FindKey( tmp );
	}
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
// Purpose: Creates a message to send to a friend - returns NULL if user unknown
//-----------------------------------------------------------------------------
ISendMessage *CServerSession::CreateUserMessage(unsigned int userID, int msgID)
{
	CBuddy *bud = GetDoc()->GetBuddy(userID);
	if (!bud)
		return NULL;

	KeyValues *buddy = bud->Data();
	if (!buddy)
		return NULL;

	ISendMessage *msg = m_pNet->CreateMessage(msgID);

	// get address
	CNetAddress addr;
	addr.SetIP(buddy->GetInt("IP"));
	addr.SetPort(buddy->GetInt("Port"));
	msg->SetNetAddress(addr);

	msg->SetEncrypted(true);

	// set the session ID to be the session ID of the target
	msg->SetSessionID(buddy->GetInt("SessionID"));

	return msg;
}
//---------------------------------------------------------------------
// Purpose: Parse session properties and contexts from the resource file
//---------------------------------------------------------------------
void CSessionBrowserDialog::ApplySettings( KeyValues *pResourceData )
{
	BaseClass::ApplySettings( pResourceData );

	KeyValues *pScenarios = pResourceData->FindKey( "ScenarioInfoPanels" );
	if ( pScenarios )
	{
		for ( KeyValues *pScenario = pScenarios->GetFirstSubKey(); pScenario != NULL; pScenario = pScenario->GetNextKey() )
		{
			CScenarioInfoPanel *pScenarioInfo = new CScenarioInfoPanel( this, "ScenarioInfoPanel" );
			SETUP_PANEL( pScenarioInfo );
			pScenarioInfo->m_pTitle->SetText( pScenario->GetString( "title" ) );
			pScenarioInfo->m_pSubtitle->SetText( pScenario->GetString( "subtitle" ) );
			pScenarioInfo->m_pMapImage->SetImage( pScenario->GetString( "image" ) );

			int nTall = pScenario->GetInt( "tall", -1 );
			if ( nTall > 0 )
			{
				pScenarioInfo->SetTall( nTall );
			}

			int nXPos = pScenario->GetInt( "xpos", -1 );
			if ( nXPos >= 0 )
			{
				int x, y;
				pScenarioInfo->GetPos( x, y );
				pScenarioInfo->SetPos( nXPos, y );
			}

			int nDescOneYpos = pScenario->GetInt( "descOneY", -1 );
			if ( nDescOneYpos > 0 )
			{
				int x, y;
				pScenarioInfo->m_pDescOne->GetPos( x, y );
				pScenarioInfo->m_pDescOne->SetPos( x, nDescOneYpos );
			}

			int nDescTwoYpos = pScenario->GetInt( "descTwoY", -1 );
			if ( nDescTwoYpos > 0 )
			{
				int x, y;
				pScenarioInfo->m_pDescTwo->GetPos( x, y );
				pScenarioInfo->m_pDescTwo->SetPos( x, nDescTwoYpos );
			}

			m_pScenarioInfos.AddToTail( pScenarioInfo );
		}
	}
}
Ejemplo n.º 10
0
	//-----------------------------------------------------------------------------
	// Purpose: Shared script resource of voice menu commands and hud strings
	//-----------------------------------------------------------------------------
	void CMultiplayRules::LoadVoiceCommandScript( void )
	{
		KeyValues *pKV = new KeyValues( "VoiceCommands" );

		if ( pKV->LoadFromFile( filesystem, "scripts/voicecommands.txt", "GAME" ) )
		{
			for ( KeyValues *menu = pKV->GetFirstSubKey(); menu != NULL; menu = menu->GetNextKey() )
			{
				int iMenuIndex = m_VoiceCommandMenus.AddToTail();

				int iNumItems = 0;

				// for each subkey of this menu, add a menu item
				for ( KeyValues *menuitem = menu->GetFirstSubKey(); menuitem != NULL; menuitem = menuitem->GetNextKey() )
				{
					iNumItems++;

					if ( iNumItems > 9 )
					{
						Warning( "Trying to load more than 9 menu items in voicecommands.txt, extras ignored" );
						continue;
					}

					VoiceCommandMenuItem_t item;

#ifndef CLIENT_DLL
					int iConcept = GetMPConceptIndexFromString( menuitem->GetString( "concept", "" ) );
					if ( iConcept == MP_CONCEPT_NONE )
					{
						Warning( "Voicecommand script attempting to use unknown concept. Need to define new concepts in code. ( %s )\n", menuitem->GetString( "concept", "" ) );
					}
					item.m_iConcept = iConcept;

					item.m_bShowSubtitle = ( menuitem->GetInt( "show_subtitle", 0 ) > 0 );
					item.m_bDistanceBasedSubtitle = ( menuitem->GetInt( "distance_check_subtitle", 0 ) > 0 );

					Q_strncpy( item.m_szGestureActivity, menuitem->GetString( "activity", "" ), sizeof( item.m_szGestureActivity ) ); 
#else
					Q_strncpy( item.m_szSubtitle, menuitem->GetString( "subtitle", "" ), MAX_VOICE_COMMAND_SUBTITLE );
					Q_strncpy( item.m_szMenuLabel, menuitem->GetString( "menu_label", "" ), MAX_VOICE_COMMAND_SUBTITLE );

#endif
					m_VoiceCommandMenus.Element( iMenuIndex ).AddToTail( item );
				}
			}
		}

		pKV->deleteThis();
	}
Ejemplo n.º 11
0
void OverrideDefaultsForModel( const char *keyname, simplifyparams_t &params )
{
	KeyValues *pKeys = g_pModelConfig;
	while ( pKeys )
	{
		if ( !Q_stricmp( pKeys->GetName(), keyname ) )
		{
			for ( KeyValues *pData = pKeys->GetFirstSubKey(); pData; pData = pData->GetNextKey() )
			{
				if ( !Q_stricmp( pData->GetName(), "tolerance" ) )
				{
					params.tolerance = pData->GetFloat();
					if (!g_bQuiet)
					{
						Msg("%s: tolerance set to %.2f\n", keyname, params.tolerance );
					}
				}
				else if ( !Q_stricmp( pData->GetName(), "addAABB" ) )
				{
					params.addAABBToSimplifiedHull = pData->GetInt() ? true : false;
					if (!g_bQuiet)
					{
						Msg("%s: AABB %s\n", keyname, params.addAABBToSimplifiedHull ? "on" : "off" );
					}
				}
				else if ( !Q_stricmp( pData->GetName(), "singleconvex" ) )
				{
					params.forceSingleConvex = pData->GetInt() ? true : false;
					if (!g_bQuiet)
					{
						Msg("%s: Forced to single convex\n", keyname );
					}
				}
				else if ( !Q_stricmp( pData->GetName(), "mergeconvex" ) )
				{
					params.mergeConvexTolerance = pData->GetFloat();
					params.mergeConvexElements = params.mergeConvexTolerance > 0 ? true : false;
					if (!g_bQuiet)
					{
						Msg("%s: Merge convex %.2f\n", keyname, params.mergeConvexTolerance );
					}
				}
			}
			return;
		}
		pKeys = pKeys->GetNextKey();
	}
}
Ejemplo n.º 12
0
//-----------------------------------------------------------------------------
// Purpose: User clicked on item: remember where last active row/column was
//-----------------------------------------------------------------------------
void COptionsSubKeyboard::ItemSelected(int itemID)
{
	m_pKeyBindList->SetItemOfInterest(itemID);

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

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

			if (kv->GetInt("Header"))
			{
				m_pSetBindingButton->SetEnabled(false);
			}
		}
	}
	else
	{
		m_pSetBindingButton->SetEnabled(false);
		m_pClearBindingButton->SetEnabled(false);
	}
}
void CreateWorldVertexTransitionPatchedMaterial( const char *pOriginalMaterialName, const char *pPatchedMaterialName )
{
	KeyValues *kv = LoadMaterialKeyValues( pOriginalMaterialName, 0 );
	if( kv )
	{
		// change shader to Lightmappedgeneric (from worldvertextransition*)
		kv->SetName( "LightmappedGeneric" );
		// don't need no stinking $basetexture2 or any other second texture vars
		RemoveKey( kv, "$basetexture2" );
		RemoveKey( kv, "$bumpmap2" );
		RemoveKey( kv, "$bumpframe2" );
		RemoveKey( kv, "$basetexture2noenvmap" );
		RemoveKey( kv, "$blendmodulatetexture" );
		RemoveKey( kv, "$maskedblending" );
		RemoveKey( kv, "$surfaceprop2" );
		// If we didn't want a basetexture on the first texture in the blend, we don't want an envmap at all.
		KeyValues *basetexturenoenvmap = kv->FindKey( "$BASETEXTURENOENVMAP" );
		if( basetexturenoenvmap->GetInt() )
		{
			RemoveKey( kv, "$envmap" );
		}

		Warning( "Patching WVT material: %s\n", pPatchedMaterialName );
		WriteMaterialKeyValuesToPak( pPatchedMaterialName, kv );
	}
}
Ejemplo n.º 14
0
//-----------------------------------------------------------------------------
// Purpose: refreshes the gamesound list
//-----------------------------------------------------------------------------
void CSoundPicker::RefreshGameSoundList()
{
	if ( !m_pGameSoundList )
		return;

	// Check the filter matches
	int nMatchingGameSounds = 0;
	int nTotalCount = 0;
	for ( int nItemID = m_pGameSoundList->FirstItem(); nItemID != m_pGameSoundList->InvalidItemID(); nItemID = m_pGameSoundList->NextItem( nItemID ) )
	{
		KeyValues *kv = m_pGameSoundList->GetItem( nItemID );
		int hGameSound = kv->GetInt( "gameSoundHandle", SoundEmitterSystem()->InvalidIndex() );
		if ( hGameSound == SoundEmitterSystem()->InvalidIndex() )
			continue;
		bool bIsVisible = IsGameSoundVisible( hGameSound );
		m_pGameSoundList->SetItemVisible( nItemID, bIsVisible );
		if ( bIsVisible )
		{
			++nMatchingGameSounds;
		}
		++nTotalCount;
	}

	UpdateGameSoundColumnHeader( nMatchingGameSounds, nTotalCount );

	if ( ( m_pGameSoundList->GetSelectedItemsCount() == 0 ) && ( m_pGameSoundList->GetItemCount() > 0 ) )
	{
		int nItemID = m_pGameSoundList->GetItemIDFromRow( 0 );
		// This prevents the refreshing of the sound list from playing the sound
		++m_nSoundSuppressionCount;
		m_pGameSoundList->SetSelectedCell( nItemID, 0 );
	}
}
static float FindPoseCycle( StudioModel *model, int sequence )
{
	float cycle = 0.0f;
	if ( !model->GetStudioHdr() )
		return cycle;

	KeyValues *seqKeyValues = new KeyValues("");
	if ( seqKeyValues->LoadFromBuffer( model->GetFileName( ), model->GetKeyValueText( sequence ) ) )
	{
		// Do we have a build point section?
		KeyValues *pkvAllFaceposer = seqKeyValues->FindKey("faceposer");
		if ( pkvAllFaceposer )
		{
			int thumbnail_frame = pkvAllFaceposer->GetInt( "thumbnail_frame", 0 );
			if ( thumbnail_frame )
			{
				// Convert frame to cycle if we have valid data
				int maxFrame = model->GetNumFrames( sequence ) - 1;

				if ( maxFrame > 0 )
				{
					cycle = thumbnail_frame / (float)maxFrame;
				}
			}
		}
	}

	seqKeyValues->deleteThis();

	return cycle;
}
//-----------------------------------------------------------------
// Purpose: Change properties of a menu item
//-----------------------------------------------------------------
void CSessionOptionsDialog::OverrideMenuItem( KeyValues *pItemKeys )
{
	if ( m_bModifySession && m_pDialogKeys )
	{
		if ( !Q_stricmp( pItemKeys->GetName(), "OptionsItem" ) )
		{
			const char *pID	= pItemKeys->GetString( "id", "NULL" );

			KeyValues *pKey = m_pDialogKeys->FindKey( pID );
			if ( pKey )
			{
				pItemKeys->SetInt( "activeoption", pKey->GetInt( "optionindex" ) );	
			}
		}
	}

	//
	// When hosting a new session on LIVE:
	//	- restrict max number of players to bandwidth allowed
	//
	if ( !m_bModifySession &&
		( !Q_stricmp( m_szGametype, "hoststandard" ) || !Q_stricmp( m_szGametype, "hostranked" ) )
		)
	{
		if ( !Q_stricmp( pItemKeys->GetName(), "OptionsItem" ) )
		{
			const char *pID	= pItemKeys->GetString( "id", "NULL" );
			if ( !Q_stricmp( pID, "PROPERTY_GAME_SIZE" ) )
			{
				pItemKeys->SetInt( "activeoption", GetMaxPlayersRecommendedOption() );
			}
		}
	}
}
int CASW_Mission_Chooser_Source_Local::GetNumMissionsCompleted(const char *szSaveName)
{
	Msg("GetNumMissionsCompleted %s\n", szSaveName);
	// check the save file exists
	char stripped[MAX_PATH];
	V_StripExtension( szSaveName, stripped, MAX_PATH );
	Msg("  stripped = %s\n", stripped);
	char tempfile[MAX_PATH];
	Q_snprintf( tempfile, sizeof( tempfile ), "save/%s.campaignsave", stripped );
	Msg("  tempfile = %s\n", tempfile);
	Q_strlower( tempfile );
	Msg("  tempfile lowered = %s\n", tempfile);
	if (!g_pFullFileSystem->FileExists(tempfile))
	{
		Msg("  this save doesn't exist! returning -1 missions\n");		
		return -1;
	}

	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile))
	{
		int iMissions = pSaveKeyValues->GetInt("NumMissionsComplete");
		pSaveKeyValues->deleteThis();
		Msg(" loaded keyvalues from file and it thinks num missions is %d\n", iMissions);
		return iMissions;
	}
	
	Msg("  Couldn't load save keyvalues from file, returning -1\n");
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile, "MOD"))
		Msg("  but it loaded if we use the MOD path\n");
	else if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile, "GAME"))
		Msg("  but it loaded if we use the GAME path\n");
	pSaveKeyValues->deleteThis();
	return -1;
}
Ejemplo n.º 18
0
void CASW_Location_Group::LoadFromKeyValues( KeyValues *pKeys )
{
    m_iRequiredUnlocks = pKeys->GetInt( "RequiredUnlocks", 0 );
    m_Color = pKeys->GetColor( "Color" );
    m_szGroupName = TileGenCopyString( pKeys->GetString( "Name" ) );
    m_szTitleText = TileGenCopyString( pKeys->GetString( "TitleText" ) );
    m_szDescriptionText = TileGenCopyString( pKeys->GetString( "DescriptionText" ) );
    m_szImageName = TileGenCopyString( pKeys->GetString( "ImageName" ) );

    // check all keys for unlock IDs
    m_UnlockedBy.Purge();
    m_Locations.PurgeAndDeleteElements();
    for ( KeyValues *pSubKey = pKeys->GetFirstSubKey(); pSubKey; pSubKey = pSubKey->GetNextKey() )
    {
        if ( !Q_stricmp( pSubKey->GetName(), "UnlockMissionID" ) )
        {
            m_UnlockedBy.AddToTail( pSubKey->GetInt() );
        }
        else if ( !Q_stricmp( pSubKey->GetName(), "Location" ) )
        {
            CASW_Location *pLocation = new CASW_Location( m_pLocationGrid );
            pLocation->LoadFromKeyValues( pSubKey, &m_Random );
            pLocation->m_pGroup = this;
            m_Locations.AddToTail( pLocation );
        }
    }
}
Ejemplo n.º 19
0
//-----------------------------------------------------------------------------
// VMT parser
//-----------------------------------------------------------------------------
static void InsertKeyValues( KeyValues &dst, KeyValues& src, bool bCheckForExistence )
{
	KeyValues *pSrcVar = src.GetFirstSubKey();
	while( pSrcVar )
	{
		if ( !bCheckForExistence || dst.FindKey( pSrcVar->GetName() ) )
		{
			switch( pSrcVar->GetDataType() )
			{
			case KeyValues::TYPE_STRING:
				dst.SetString( pSrcVar->GetName(), pSrcVar->GetString() );
				break;
			case KeyValues::TYPE_INT:
				dst.SetInt( pSrcVar->GetName(), pSrcVar->GetInt() );
				break;
			case KeyValues::TYPE_FLOAT:
				dst.SetFloat( pSrcVar->GetName(), pSrcVar->GetFloat() );
				break;
			case KeyValues::TYPE_PTR:
				dst.SetPtr( pSrcVar->GetName(), pSrcVar->GetPtr() );
				break;
			}
		}
		pSrcVar = pSrcVar->GetNextKey();
	}
}
Ejemplo n.º 20
0
//-----------------------------------------------------------------------------
// Purpose: Sets the game filter combo box to be the saved setting
//-----------------------------------------------------------------------------
void CBaseGamesPage::UpdateGameFilter()
{
	bool bFound = false;
	for (int i = 0; i < m_pGameFilter->GetItemCount(); i++)
	{
		KeyValues *kv = m_pGameFilter->GetItemUserData(i);
		int iAppID = kv->GetInt( "appID", 0 );
		const char *pchGameDir = kv->GetString( "gamedir" );
		if ( iAppID == m_iLimitToAppID && ( !m_szGameFilter[0] || !Q_strncmp( pchGameDir, m_szGameFilter, Q_strlen( pchGameDir ) ) ) )
		{
			if ( i != m_pGameFilter->GetActiveItem() )
			{
				m_pGameFilter->ActivateItem(i);
			}
			bFound = true;
			break;
		}
	}
	if (!bFound)
	{
		// default to empty
		if ( 0 != m_pGameFilter->GetActiveItem() )
		{
			m_pGameFilter->ActivateItem(0);
		}
	}

	// only one mod is allowed in the game
	if ( ServerBrowserDialog().GetActiveModName() )
	{
		m_pGameFilter->SetEnabled( false );
		m_pGameFilter->SetText( ServerBrowserDialog().GetActiveGameName() );
	}
}
Ejemplo n.º 21
0
void CHalfLife2Survival::ParseSurvivalSettings( KeyValues *pSubKey )
{
	if ( pSubKey == NULL )
		return;

	m_SurvivalSettings.m_szPickups = NULL_STRING;
	m_SurvivalSettings.m_iSpawnHealth = 100;

	KeyValues *pTestKey = pSubKey->GetFirstSubKey();

	while ( pTestKey )
	{
		if ( !stricmp( pTestKey->GetName(), "weapons" ) )
		{
			const char *pLoadout =  pTestKey->GetString();
			Q_SplitString( pLoadout, ";", m_SurvivalSettings.m_Loadout );
		}
		else if ( !stricmp( pTestKey->GetName(), "spawnhealth" ) )
		{
			m_SurvivalSettings.m_iSpawnHealth = pTestKey->GetInt( 0, 100 );
		}
		else if ( !stricmp( pTestKey->GetName(), "allowedpickups" ) )
		{
			m_SurvivalSettings.m_szPickups = MAKE_STRING( pTestKey->GetString() );
		}
		
		pTestKey = pTestKey->GetNextKey();
	}
}
Ejemplo n.º 22
0
int UTIL_GetMapKeyCount( const char *pszCustomKey )
{
	if ( !pszCustomKey )
		return 0;

	char szFilename[ _MAX_PATH ];
	if ( !UTIL_GetMapLoadCountFileName( MAP_KEY_FILE, szFilename, _MAX_PATH ) )
		return 0;

	int iCount = 0;

	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 );

		KeyValues *pMapKey = kvMapLoadFile->FindKey( mapname );
		if ( pMapKey )
		{
			iCount = pMapKey->GetInt( pszCustomKey );
		}

		kvMapLoadFile->deleteThis();
	}

	return iCount;
}
int	CMDLSequencePicker::GetSequenceNumber()
{
	int nIndex = m_pSequencesList->GetSelectedItem( 0 );
	if ( nIndex < 0 )
		return -1;
	KeyValues *pkv = m_pSequencesList->GetItem( nIndex );
	return pkv->GetInt( "seqindex", -1 );
}
Ejemplo n.º 24
0
int CTFInventory::GetLocalPreset(KeyValues* pInventory, int iClass, int iSlot)
{
	KeyValues *pSub = pInventory->FindKey(g_aPlayerClassNames_NonLocalized[iClass]);
	if (!pSub)
		return 0;
	const int iPreset = pSub->GetInt(g_aPlayerSlotNames[iSlot], 0);
	return iPreset;
};
Ejemplo n.º 25
0
//-----------------------------------------------------------------------------
// Purpose: Parse data found from npcData keyValue...
//-----------------------------------------------------------------------------
void CNPC_Monster::ParseNPCScript( const char *szScript )
{
	// Get our data and make sure it is not NULL...
	KeyValues *pkvMyNPCData = pkvNPCData(szScript);
	if (!pkvMyNPCData)
	{
		Warning("NPC_MONSTER linked to %s.txt was removed, no such script exist!\n", szScript);
		UTIL_Remove(this);
		return;
	}

	// Parse our data:
	KeyValues *pkvInfoField = pkvMyNPCData->FindKey("Info");
	KeyValues *pkvModelField = pkvMyNPCData->FindKey("Model");
	KeyValues *pkvRandomModelsField = pkvMyNPCData->FindKey("Models");

	bool bRandomModel = false;

	if (pkvInfoField)
	{
		cEntName = MAKE_STRING(ReadAndAllocStringValue(pkvInfoField, "Name"));
		cSoundScript = MAKE_STRING(ReadAndAllocStringValue(pkvInfoField, "SoundScript"));

		m_iHealth = pkvInfoField->GetInt("Health", 100);
		m_iDamage[0] = pkvInfoField->GetInt("DamageOneHand", 10);
		m_iDamage[1] = pkvInfoField->GetInt("DamageBothHands", 10);
		m_flAttackRange = pkvInfoField->GetFloat("AttackRange", 70.0f);
		m_iMaxHealth = m_iHealth;
		m_bCanOpenDoors = ((pkvInfoField->GetInt("CanOpenDoors") >= 1) ? true : false);
	}

	if (pkvModelField)
	{
		bRandomModel = (!pkvModelField->FindKey("Path"));

		if (!bRandomModel)
			cModel = MAKE_STRING(ReadAndAllocStringValue(pkvModelField, "Path"));

		m_fIsTorso = ((pkvModelField->GetInt("IsTorso") >= 1) ? true : false);

		if (!strcmp(pkvModelField->GetString("Skin"), "random"))
			m_iSkin = random->RandomInt(0, pkvModelField->GetInt("MaxSkins"));
		else
			m_iSkin = pkvModelField->GetInt("Skin");

		SetBloodColor(pkvModelField->GetInt("BloodType"));
	}

	if (pkvRandomModelsField && bRandomModel)
		cModel = MAKE_STRING(GetRandomModel(pkvRandomModelsField));

	Precache();

	pkvMyNPCData->deleteThis();
}
Ejemplo n.º 26
0
	virtual void OnDragFailed( CUtlVector< KeyValues * >& msglist )
	{
		PropertySheet *sheet = IsDroppingSheet( msglist );
		if ( !sheet )
			return;

		// Create a new property sheet
		if ( m_pParent->IsDraggableTab() )
		{
			if ( msglist.Count() == 1 )
			{
				KeyValues *data = msglist[ 0 ];
                int screenx = data->GetInt( "screenx" );
				int screeny = data->GetInt( "screeny" );

				// m_pParent->ScreenToLocal( screenx, screeny );
				if ( !m_pParent->IsWithin( screenx, screeny ) )
				{
					Panel *page = reinterpret_cast< Panel * >( data->GetPtr( "propertypage" ) );
					PropertySheet *sheet = reinterpret_cast< PropertySheet * >( data->GetPtr( "propertysheet" ) );
					char const *title = data->GetString( "tabname", "" );
					if ( !page || !sheet )
						return;
					
					// Can only create if sheet was part of a ToolWindow derived object
					ToolWindow *tw = dynamic_cast< ToolWindow * >( sheet->GetParent() );
					if ( tw )
					{
						IToolWindowFactory *factory = tw->GetToolWindowFactory();
						if ( factory )
						{
							bool hasContextMenu = sheet->PageHasContextMenu( page );
							sheet->RemovePage( page );
							factory->InstanceToolWindow( tw->GetParent(), sheet->ShouldShowContextButtons(), page, title, hasContextMenu );

							if ( sheet->GetNumPages() == 0 )
							{
								tw->MarkForDeletion();
							}
						}
					}
				}
			}
		}
	}
Ejemplo n.º 27
0
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
	}
}
Ejemplo n.º 28
0
//-----------------------------------------------------------------------------
// Purpose: Places all the info from the vgui controls into the QCInfo struct
//-----------------------------------------------------------------------------
void QCInfo::SyncFromControls()
{
	char tempText[MAX_PATH];
	
	vgui::Panel *pTargetField = pQCGenerator->FindChildByName( "staticPropCheck" );
	bStaticProp = ((CheckButton *)pTargetField)->IsSelected();
	 
	pTargetField = pQCGenerator->FindChildByName( "mostlyOpaqueCheck" );
	bMostlyOpaque = ((CheckButton *)pTargetField)->IsSelected();

	pTargetField = pQCGenerator->FindChildByName( "disableCollisionsCheck" );
	bDisableCollision = ((CheckButton *)pTargetField)->IsSelected();

	pTargetField = pQCGenerator->FindChildByName( "referencePhysicsCheck" );
	bReferenceAsPhys = ((CheckButton *)pTargetField)->IsSelected();

	pTargetField = pQCGenerator->FindChildByName( "concaveCheck" );
	bConcave = ((CheckButton *)pTargetField)->IsSelected();

	pTargetField = pQCGenerator->FindChildByName( "automassCheck" );
	bAutomass = ((CheckButton *)pTargetField)->IsSelected();

	pTargetField = pQCGenerator->FindChildByName( "massField" );
	((TextEntry *)pTargetField)->GetText(tempText, MAX_PATH);
	fMass = atof(tempText);

	pTargetField = pQCGenerator->FindChildByName( "scaleField" );
	((TextEntry *)pTargetField)->GetText(tempText, MAX_PATH);
	fScale = atof(tempText);

    pTargetField = pQCGenerator->FindChildByName( "collisionSMDField" );
	((TextEntry *)pTargetField)->GetText( tempText, MAX_PATH );	
	Q_strcpy( pszCollisionPath, tempText );

	pTargetField = pQCGenerator->FindChildByName( "surfacePropertyDropDown" );
	((ComboBox *)pTargetField)->GetText( tempText, MAX_PATH );
    Q_strcpy( pszSurfaceProperty, tempText );

	pTargetField = pQCGenerator->FindChildByName( "materialsField" );
	((TextEntry *)pTargetField)->GetText( tempText, MAX_PATH );
	Q_strcpy( pszMaterialPath, tempText );

	LODs.RemoveAll();
	pTargetField = pQCGenerator->FindChildByName( "LODList" );
	int numLOD = ((ListPanel *)pTargetField)->GetItemCount();
	for ( int i = 0; i < numLOD; i++ )
	{
		KeyValues *key = ((ListPanel *)pTargetField)->GetItem( i );
		LODInfo newLOD;

		Q_strcpy( newLOD.pszFilename, key->GetString( "SMD" ) );
		newLOD.iLOD = key->GetInt( "LOD" );		
        LODs.AddToTail( newLOD );
	}
}
Ejemplo n.º 29
0
//-----------------------------------------------------------------------------
// Purpose: Returns true if the specified panel can be the default
//-----------------------------------------------------------------------------
bool FocusNavGroup::CanButtonBeDefault(VPANEL panel)
{
	KeyValues *data = new KeyValues("CanBeDefaultButton");

	bool bResult = false;
	if (ipanel()->RequestInfo(panel, data))
	{
		bResult = (data->GetInt("result") == 1);
	}
	data->deleteThis();
	return bResult;
}
void CGECharacterDataParser::Parse( KeyValues *pKeyValuesData, const char *szFileWithoutEXT )
{
	CGECharData *pChar = g_GECharacters.Add( szFileWithoutEXT );

	Q_strncpy( pChar->szPrintName,	pKeyValuesData->GetString("printname",		"#GE_UNNAMED"),	MAX_CHAR_IDENT );
	Q_strncpy( pChar->szShortName,	pKeyValuesData->GetString("shortname",		"#GE_UNNAMED"),	MAX_CHAR_NAME  );
	Q_strncpy( pChar->szBio,		pKeyValuesData->GetString("bio",			""			 ),	MAX_CHAR_BIO   );

	// Load our weight
	pChar->iWeight = pKeyValuesData->GetInt( "weight" );

	// Affiliate them with a team
	const char *team = pKeyValuesData->GetString( "team", "unassigned" );
	if ( !Q_stricmp(team, "mi6") )
		pChar->iTeam = TEAM_MI6;
	else if ( !Q_stricmp(team, "janus") )
		pChar->iTeam = TEAM_JANUS;
	else
		pChar->iTeam = TEAM_UNASSIGNED;

	const char *gender = pKeyValuesData->GetString( "gender", "m" );
	if ( gender[0] == 'f' )
		pChar->iGender = CHAR_GENDER_FEMALE;
	else
		pChar->iGender = CHAR_GENDER_MALE;

	// Load our skins in
	KeyValues *pSkinValues = pKeyValuesData->FindKey( "skins" );
	if ( pSkinValues )
	{
		KeyValues *pSkinData = pSkinValues->GetFirstSubKey();
		for( int i=0; i < MAX_CHAR_SKINS; i++ )
		{
			if( pSkinData == NULL )
				break;

			GECharSkin *skin = new GECharSkin;

			Q_strncpy( skin->szIdent,		pSkinData->GetName(),								MAX_CHAR_IDENT );
			Q_strncpy( skin->szPreviewImg,	pSkinData->GetString("previewimg", "unknown"	 ),	MAX_CHAR_NAME  );
			Q_strncpy( skin->szModel,		pSkinData->GetString("model",	   ""			 ),	MAX_MODEL_PATH );
			Q_strncpy( skin->szHatModel,	pSkinData->GetString("hatmodel",   ""			 ),	MAX_MODEL_PATH );
			
			skin->iViewSkin	 = pSkinData->GetInt( "viewmodelskin",  0 );
			skin->iWorldSkin = pSkinData->GetInt( "worldmodelskin", 0 );

			// TODO: We need to error check this input....
			pChar->m_pSkins.AddToTail( skin );

			pSkinData = pSkinData->GetNextKey();
		}
	}
}