Example #1
0
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;
}
Example #2
0
//-----------------------------------------------------------------------------
// Purpose: Resets the list of players
//-----------------------------------------------------------------------------
void CSpectatorMenu::Update( void )
{
	int itemID = 0;

	IGameResources *gr = GameResources();

	Reset();

	if( m_iDuckKey < 0 )
	{
		m_iDuckKey = gameuifuncs->GetEngineKeyCodeForBind( "duck" );
	}
	
	if ( !gr )
		return;

	int iPlayerIndex;
	for ( iPlayerIndex = 1 ; iPlayerIndex <= gpGlobals->maxClients; iPlayerIndex++ )
	{

		// does this slot in the array have a name?
		if ( !gr->IsConnected( iPlayerIndex ) )
			continue;
			
		if ( gr->IsLocalPlayer( iPlayerIndex ) )
			continue;

		if ( !gr->IsAlive( iPlayerIndex ) )
			continue;

		wchar_t playerText[ 80 ], playerName[ 64 ], *team, teamText[ 64 ];
		char localizeTeamName[64];
		localize()->ConvertANSIToUnicode( UTIL_SafeName( gr->GetPlayerName(iPlayerIndex) ), playerName, sizeof( playerName ) );
		const char * teamname = gr->GetTeamName( gr->GetTeam(iPlayerIndex) );
		if ( teamname )
		{	
			Q_snprintf( localizeTeamName, sizeof( localizeTeamName ), "#%s", teamname );
			team=localize()->Find( localizeTeamName );

			if ( !team ) 
			{
				localize()->ConvertANSIToUnicode( teamname , teamText, sizeof( teamText ) );
				team = teamText;
			}

			localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem_Team" ), 2, playerName, team );
		}
		else
		{
			localize()->ConstructString( playerText, sizeof( playerText ), localize()->Find( "#Spec_PlayerItem" ), 1, playerName );
		}

		KeyValues *kv = new KeyValues("UserData", "player", gr->GetPlayerName( iPlayerIndex ) );
		itemID = PlayerAddItem( itemID, playerText, kv ); // -1 means a new slot
		kv->deleteThis();
	}

	// make sure the player combo box is up to date
	int playernum = GetSpectatorTarget();
	const char *selectedPlayerName = gr->GetPlayerName( playernum );
	for ( iPlayerIndex=0; iPlayerIndex<m_pPlayerList->GetItemCount(); ++iPlayerIndex )
	{
		KeyValues *kv = m_pPlayerList->GetItemUserData( iPlayerIndex );
		if ( kv && FStrEq( kv->GetString( "player" ), selectedPlayerName ) )
		{
			m_pPlayerList->ActivateItemByRow( iPlayerIndex );
			m_pPlayerList->SetText( selectedPlayerName );
			break;
		}
	}
}
KeyValues* ReadEncryptedKVFile( IFileSystem *filesystem, const char *szFilenameWithoutExtension, const unsigned char *pICEKey, bool bForceReadEncryptedFile /*= false*/ )
{
	Assert( strchr( szFilenameWithoutExtension, '.' ) == NULL );
	char szFullName[512];

	const char *pSearchPath = "MOD";

	if ( pICEKey == NULL )
	{
		pSearchPath = "GAME";
	}

	// Open the weapon data file, and abort if we can't
	KeyValues *pKV = new KeyValues( "WeaponDatafile" );

	Q_snprintf(szFullName,sizeof(szFullName), "%s.txt", szFilenameWithoutExtension);

	if ( bForceReadEncryptedFile || !pKV->LoadFromFile( filesystem, szFullName, pSearchPath ) ) // try to load the normal .txt file first
	{
#ifndef _XBOX
		if ( pICEKey )
		{
			Q_snprintf(szFullName,sizeof(szFullName), "%s.ctx", szFilenameWithoutExtension); // fall back to the .ctx file

			FileHandle_t f = filesystem->Open( szFullName, "rb", pSearchPath );

			if (!f)
			{
				pKV->deleteThis();
				return NULL;
			}
			// load file into a null-terminated buffer
			int fileSize = filesystem->Size(f);
			char *buffer = (char*)MemAllocScratch(fileSize + 1);
		
			Assert(buffer);
		
			filesystem->Read(buffer, fileSize, f); // read into local buffer
			buffer[fileSize] = 0; // null terminate file as EOF
			filesystem->Close( f );	// close file after reading

			UTIL_DecodeICE( (unsigned char*)buffer, fileSize, pICEKey );

			bool retOK = pKV->LoadFromBuffer( szFullName, buffer, filesystem );

			MemFreeScratch();

			if ( !retOK )
			{
				pKV->deleteThis();
				return NULL;
			}
		}
		else
		{
			pKV->deleteThis();
			return NULL;
		}
#else
		pKV->deleteThis();
		return NULL;
#endif
	}

	return pKV;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CMaterialSubRect::PrecacheVars( KeyValues * pVMTKeyValues, KeyValues * pPatchKeyValues, CUtlVector<FileNameHandle_t> *pIncludes )
{
	// FIXME:  Should call through to the parent material for all of this???
	// We should get both parameters or neither
	Assert( ( pVMTKeyValues == NULL ) ? ( pPatchKeyValues == NULL ) : ( pPatchKeyValues != NULL ) );

	// Are we already precached?
	if( IsPrecachedVars() )
		return true;

	// load data from the vmt file
	bool bOk = false;
	KeyValues *vmtKeyValues = NULL;
	KeyValues *patchKeyValues = NULL;
	if ( m_pVMTKeyValues )
	{
		// Use the procedural KeyValues
		vmtKeyValues = m_pVMTKeyValues;
		patchKeyValues = new KeyValues( "vmt_patches" );

		// The caller should not be passing in KeyValues if we have procedural ones
		Assert( ( pVMTKeyValues == NULL ) && ( pPatchKeyValues == NULL ) );
	}
	else if ( pVMTKeyValues )
	{
		// Use the passed-in (already-loaded) KeyValues
		vmtKeyValues = pVMTKeyValues;
		patchKeyValues = pPatchKeyValues;
	}
	else
	{
		// load data from the vmt file
		vmtKeyValues = new KeyValues( "vmt" );
		patchKeyValues = new KeyValues( "vmt_patches" );
		if( !LoadVMTFile( *vmtKeyValues, *patchKeyValues, GetName(), UsesUNCFileName(), NULL ) )
		{
			Warning( "CMaterialSubRect::PrecacheVars: error loading vmt file for %s\n", GetName() );
			goto precacheVarsDone;
		}
	}

	// Get the "Subrect" material vars.
	ParseMaterialVars( *vmtKeyValues );

	// Setup the "Subrect" material vars.
	SetupMaterialVars();

	// Vars are precached.
	m_fLocal |= MATERIALSUBRECT_VARS_IS_PRECACHED;
	bOk = true;

precacheVarsDone:
	// Clean up
	if ( ( vmtKeyValues != m_pVMTKeyValues ) && ( vmtKeyValues != pVMTKeyValues ) )
	{
		vmtKeyValues->deleteThis();
	}
	if ( patchKeyValues != pPatchKeyValues )
	{
		patchKeyValues->deleteThis();
	}

	return bOk;
}
Example #5
0
void CFolderMenu::Update()
{
	ReloadControlSettings(false, false);

	MoveToCenterOfScreen();

	Button *entry = dynamic_cast<Button *>(FindChildByName("ApproveButton"));
	if (entry)
		entry->SetVisible(true);

	C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer();

	if (!pPlayer)
		return;

	if (pPlayer->HasCharacterBeenChosen())
		Q_strcpy(m_szCharacter, pPlayer->GetCharacter());
	else
		m_szCharacter[0] = '\0';

	if (ShouldShowCharacterOnly() && !ShouldShowTeams())
	{
		m_pProfileInfo->SetVisible(true);
		if (m_szPreviewCharacter[0])
			m_pProfileInfo->SetText((std::string("#DA_CharacterInfo_") + m_szPreviewCharacter).c_str());
		else if (m_szCharacter[0])
			m_pProfileInfo->SetText((std::string("#DA_CharacterInfo_") + m_szCharacter).c_str());
		else
			m_pProfileInfo->SetText("#DA_CharacterInfo_None");
	}
	else
		m_pProfileInfo->SetVisible(false);

	CFolderLabel *pCharacterName = dynamic_cast<CFolderLabel *>(FindChildByName("AgentName"));
	if (pCharacterName)
	{
		if (!ShouldShowTeams())
		{
			std::string sCharacter;
			if (m_szPreviewCharacter[0])
				sCharacter = std::string("#DA_Character_") + m_szPreviewCharacter;
			else if (m_szCharacter[0])
				sCharacter = std::string("#DA_Character_") + m_szCharacter;

			std::wstring sLocalized;
			wchar_t* pszLocalized = g_pVGuiLocalize->Find( sCharacter.c_str() );

			if (pszLocalized)
				sLocalized += pszLocalized;

			if (pPlayer->m_Shared.m_iStyleSkillAfterRespawn)
			{
				std::string sSkill = std::string("#DA_Skill_") + SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkillAfterRespawn.Get()) + "_Adjective";

				pszLocalized = g_pVGuiLocalize->Find( sSkill.c_str() );

				if (pszLocalized)
					sLocalized += pszLocalized;
			}

			pCharacterName->SetText(sLocalized.c_str());
		}
		else
			pCharacterName->SetText("");
	}

	CFolderLabel* pLabels[2];
	pLabels[0] = dynamic_cast<CFolderLabel *>(FindChildByName("RequestedArmament1"));
	pLabels[1] = dynamic_cast<CFolderLabel *>(FindChildByName("RequestedArmament2"));

	int iArmamentsOn1 = 0;

	std::wostringstream sLabel1;
	std::wostringstream sLabel2;

	SDKWeaponID eFirst = WEAPON_NONE;
	for (int i = 0; i < MAX_LOADOUT; i++)
	{
		if (!pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i))
			continue;

		CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i);
		if (!pWeaponInfo)
			continue;

		if (!eFirst)
		{
			eFirst = (SDKWeaponID)i;

			if (pPlayer->GetLoadoutWeaponCount(eFirst) > 1)
			{
				CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo(eFirst);
				if (pWeaponInfo && pWeaponInfo->m_szAkimbo[0])
				{
					// If we have two of this weapon and this weapon has an akimbo, use the akimbo instead.
					eFirst = AliasToWeaponID(pWeaponInfo->m_szAkimbo);
				}
			}
		}
		else
		{
			if (pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) > 1)
			{
				CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i);
				if (pWeaponInfo && pWeaponInfo->m_szAkimbo[0])
				{
					SDKWeaponID eAkimbo = AliasToWeaponID(pWeaponInfo->m_szAkimbo);
					if (eAkimbo < eFirst)
					{
						// If we have this akimbo and it's preferred to the current weapon, use it instead.
						// (Preferred means lower weapon ID.)
						eFirst = eAkimbo;
					}
				}
			}
		}

		std::wostringstream sLabel;

		const wchar_t *pchFmt = g_pVGuiLocalize->Find( pWeaponInfo->szPrintName );
		if ( pchFmt && pchFmt[0] )
			sLabel << pchFmt;
		else
			sLabel << pWeaponInfo->szPrintName;

		if (pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) > 1)
			sLabel << " x" << pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i) << "\n";
		else
			sLabel << "\n";

		if (iArmamentsOn1 >= 2)
			sLabel2 << sLabel.str();
		else
			sLabel1 << sLabel.str();

		iArmamentsOn1++;
	}

	if (pLabels[0])
		pLabels[0]->SetText(sLabel1.str().c_str());

	if (pLabels[1])
		pLabels[1]->SetText(sLabel2.str().c_str());

	const char szPlayerPreviewTemplate[] =
		"	\"model\"\n"
		"	{\n"
		"		\"spotlight\"	\"1\"\n"
		"		\"modelname\"	\"models/player/frank.mdl\"\n"
		"		\"origin_z\"	\"-57\"\n"
		"		\"origin_y\"	\"10\"\n"
		"		\"origin_x\"	\"110\"\n"
		"		\"angles_y\"	\"180\"\n"

		"		\"animation\"\n"
		"		{\n"
		"			\"sequence\"		\"m1911_idle\"\n"
		"			\"pose_parameters\"\n"
		"			{\n"
		"				\"body_yaw\" \"25.0\"\n"
		"				\"body_pitch\" \"-30.0\"\n"
		"			}\n"
		"		}\n"
			
		"		\"attached_model\"\n"
		"		{\n"
		"			\"modelname\" \"models/weapons/m1911.mdl\"\n"
		"		}\n"
		"	}";

	CModelPanel *pPlayerPreview = dynamic_cast<CModelPanel *>(FindChildByName("player_preview"));
	CSDKWeaponInfo* pWeaponInfo = NULL;
	if (eFirst)
		pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo(eFirst);

	if ((m_szCharacter[0] || m_szPreviewCharacter[0]) && pPlayerPreview && !ShouldShowTeams())
	{
		KeyValues* pValues = new KeyValues("preview");
		pValues->LoadFromBuffer("model", szPlayerPreviewTemplate);

		const char* pCharacter = m_szCharacter;
		if (m_szPreviewCharacter[0])
			pCharacter = m_szPreviewCharacter;

		pValues->SetString("modelname", VarArgs("models/player/%s.mdl", pCharacter));

		if (ShouldShowCharacterOnly() || ShouldShowCharacterAndWeapons())
		{
			pValues->SetFloat("origin_x", hud_characterpreview_x.GetFloat());
			pValues->SetFloat("origin_y", hud_characterpreview_y.GetFloat());
			pValues->SetFloat("origin_z", hud_characterpreview_z.GetFloat());
		}
		else
		{
			pValues->SetFloat("origin_x", hud_playerpreview_x.GetFloat());
			pValues->SetFloat("origin_y", hud_playerpreview_y.GetFloat());
			pValues->SetFloat("origin_z", hud_playerpreview_z.GetFloat());
		}

		if (m_pPage && FStrEq(m_pPage->GetName(), "class") && m_szPreviewSequence[0] && m_szPreviewWeaponModel[0] && !pPlayer->GetLoadoutWeight())
		{
			KeyValues* pAnimation = pValues->FindKey("animation");
			if (pAnimation)
				pAnimation->SetString("sequence", m_szPreviewSequence);

			KeyValues* pWeapon = pValues->FindKey("attached_model");
			if (pWeapon)
				pWeapon->SetString("modelname", m_szPreviewWeaponModel);
		}
		else if (pWeaponInfo)
		{
			KeyValues* pAnimation = pValues->FindKey("animation");
			if (pAnimation)
				pAnimation->SetString("sequence", VarArgs("%s_idle", WeaponIDToAlias(eFirst)));

			KeyValues* pWeapon = pValues->FindKey("attached_model");
			if (pWeapon)
				pWeapon->SetString("modelname", pWeaponInfo->szWorldModel);
		}
		else
		{
			KeyValues* pAnimation = pValues->FindKey("animation");
			if (pAnimation)
				pAnimation->SetString("sequence", "idle");

			KeyValues* pWeapon = pValues->FindKey("attached_model");
			if (pWeapon)
				pWeapon->SetString("modelname", "");
		}

		if (SDKGameRules()->IsTeamplay())
		{
			if (pPlayer->GetTeamNumber() == SDK_TEAM_BLUE)
				pValues->SetInt("skin", 1);
			else if (pPlayer->GetTeamNumber() == SDK_TEAM_RED)
				pValues->SetInt("skin", 2);
			else
				pValues->SetInt("skin", 0);
		}
		else
			pValues->SetInt("skin", 0);

		pPlayerPreview->ParseModelInfo(pValues);

		pValues->deleteThis();
	}
	else if (pPlayerPreview)
		pPlayerPreview->SwapModel("");

	for ( int i = 0; i < m_apWeaponIcons.Count(); i++)
	{
		if (m_apWeaponIcons[i].m_pWeaponName)
			m_apWeaponIcons[i].m_pWeaponName->DeletePanel();
	
		if (m_apWeaponIcons[i].m_pSlots)
			m_apWeaponIcons[i].m_pSlots->DeletePanel();

		if (m_apWeaponIcons[i].m_pImage)
			m_apWeaponIcons[i].m_pImage->DeletePanel();

		if (m_apWeaponIcons[i].m_pDelete)
			m_apWeaponIcons[i].m_pDelete->DeletePanel();
	}

	m_apWeaponIcons.RemoveAll();

	const char szWeaponPreviewTemplate[] =
		"	\"model\"\n"
		"	{\n"
		"		\"spotlight\"	\"1\"\n"
		"		\"modelname\"	\"models/weapons/beretta.mdl\"\n"
		"		\"origin_x\"	\"30\"\n"
		"		\"origin_y\"	\"3\"\n"
		"		\"origin_z\"	\"-3\"\n"
		"		\"angles_y\"	\"200\"\n"
		"	}";

	Panel *pWeaponIconArea = FindChildByName("WeaponIconArea");
	if ((ShouldShowCharacterAndWeapons() || ShouldShowEverything()) && pWeaponIconArea)
	{
		int iWeaponAreaX, iWeaponAreaY, iWeaponAreaW, iWeaponAreaH;
		pWeaponIconArea->GetPos(iWeaponAreaX, iWeaponAreaY);
		pWeaponIconArea->GetSize(iWeaponAreaW, iWeaponAreaH);

		int iMargin = 5;

		int iBoxSize = (iWeaponAreaW-5)/2;

		int iWeapon = 0;

		for (int i = 0; i < MAX_LOADOUT; i++)
		{
			if (!pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i))
				continue;

			CSDKWeaponInfo* pWeaponInfo = CSDKWeaponInfo::GetWeaponInfo((SDKWeaponID)i);
			if (!pWeaponInfo)
				continue;

			for (int j = 0; j < pPlayer->GetLoadoutWeaponCount((SDKWeaponID)i); j++)
			{
				float flMoveRight = 0;
				if (iWeapon%2 == 1)
					flMoveRight = iBoxSize + iMargin;

				CWeaponIcon* pIcon = &m_apWeaponIcons[m_apWeaponIcons.AddToTail()];

				pIcon->m_pWeaponName = new CFolderLabel(this, NULL);
				pIcon->m_pWeaponName->SetText(VarArgs("#DA_Weapon_Obituary_%s", pWeaponInfo->szClassName+7)); // Use the obit version because it's shorter
				pIcon->m_pWeaponName->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + 10 + (iWeapon/2) * (iBoxSize+iMargin));
				pIcon->m_pWeaponName->SetSize(iBoxSize, 15);
				pIcon->m_pWeaponName->SetContentAlignment(Label::a_center);
				pIcon->m_pWeaponName->SetZPos(-5);
				pIcon->m_pWeaponName->SetFont(vgui::scheme()->GetIScheme(GetScheme())->GetFont("FolderLarge"));
				pIcon->m_pWeaponName->SetScheme("FolderScheme");

				std::wostringstream sSlotsLabel;

				if (pWeaponInfo->iWeight)
				{
					const wchar_t *pchFmt = g_pVGuiLocalize->Find( "#DA_BuyMenu_Weapon_Slots" );
					if ( pchFmt && pchFmt[0] )
						sSlotsLabel << pchFmt;
					else
						sSlotsLabel << "Slots: ";

					sSlotsLabel << pWeaponInfo->iWeight;

					pIcon->m_pSlots = new CFolderLabel(this, NULL);
					pIcon->m_pSlots->SetText(sSlotsLabel.str().c_str());
					pIcon->m_pSlots->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + iBoxSize - 10 + (iWeapon/2) * (iBoxSize+iMargin));
					pIcon->m_pSlots->SetSize(iBoxSize, 15);
					pIcon->m_pSlots->SetContentAlignment(Label::a_center);
					pIcon->m_pSlots->SetZPos(-5);
					pIcon->m_pSlots->SetFont(vgui::scheme()->GetIScheme(GetScheme())->GetFont("FolderSmall"));
					pIcon->m_pSlots->SetScheme("FolderScheme");
				}

				KeyValues* pValues = new KeyValues("preview");
				pValues->LoadFromBuffer("model", szWeaponPreviewTemplate);
				pValues->SetString("modelname", pWeaponInfo->szWorldModel);

				if (pWeaponInfo->m_eWeaponType == WT_PISTOL)
					pIcon->m_flDistance = 20;
				else if (pWeaponInfo->m_eWeaponType == WT_RIFLE)
					pIcon->m_flDistance = 50;
				else if (pWeaponInfo->m_eWeaponType == WT_SHOTGUN)
					pIcon->m_flDistance = 50;
				else if (pWeaponInfo->m_eWeaponType == WT_SMG)
					pIcon->m_flDistance = 30;
				else if (pWeaponInfo->m_eWeaponType == WT_GRENADE)
					pIcon->m_flDistance = 20;

				pIcon->m_pImage = new CModelPanel(this, NULL);
				pIcon->m_pImage->SetPos(iWeaponAreaX + flMoveRight, iWeaponAreaY + (iWeapon/2) * (iBoxSize+iMargin));
				pIcon->m_pImage->SetSize(iBoxSize, iBoxSize);
				pIcon->m_pImage->SetZPos(-15);
				pIcon->m_pImage->SetScheme("FolderScheme");
				pIcon->m_pImage->ParseModelInfo(pValues);

				pValues->deleteThis();

				pIcon->m_pDelete = new CImageButton(this, VarArgs("delete_%d", iWeapon));
				pIcon->m_pDelete->SetDimensions(iWeaponAreaX + iBoxSize - 8 + flMoveRight, iWeaponAreaY + 30 + (iWeapon/2) * (iBoxSize+iMargin), 12, 12);
				pIcon->m_pDelete->SetZPos(15);
				pIcon->m_pDelete->SetImage("folder_delete");
				pIcon->m_pDelete->SetPaintBorderEnabled(false);
				pIcon->m_pDelete->SetPaintBackgroundEnabled(true);
				pIcon->m_pDelete->SetCommand(VarArgs("buy remove %d", i));

				iWeapon++;
			}
		}
	}

	CFolderLabel* pWeaponTotalWeightNumber = dynamic_cast<CFolderLabel*>(FindChildByName("WeaponTotalWeightNumber"));
	CFolderLabel* pWeaponTotalWeight = dynamic_cast<CFolderLabel*>(FindChildByName("WeaponTotalWeight"));
	if ((ShouldShowCharacterAndWeapons() || ShouldShowEverything()) && pPlayer->GetLoadoutWeight())
	{
		if (pWeaponTotalWeightNumber)
		{
			wchar_t szText[20];
			_snwprintf( szText, ARRAYSIZE(szText) - 1, L"%d/%d", pPlayer->GetLoadoutWeight(), MAX_LOADOUT_WEIGHT );
			pWeaponTotalWeightNumber->SetText(szText);
			pWeaponTotalWeightNumber->SetVisible(true);
		}

		if (pWeaponTotalWeight)
			pWeaponTotalWeight->SetVisible(true);
	}
	else
	{
		if (pWeaponTotalWeightNumber)
			pWeaponTotalWeightNumber->SetVisible(false);

		if (pWeaponTotalWeight)
			pWeaponTotalWeight->SetVisible(false);
	}

	if (ShouldShowEverything())
	{
		CFolderLabel *pSkillInfo = dynamic_cast<CFolderLabel *>(FindChildByName("SkillInfo"));
		CPanelTexture *pSkillIcon = dynamic_cast<CPanelTexture *>(FindChildByName("SkillIcon"));

		if (pSkillInfo && pSkillIcon)
		{
			if (pPlayer->m_Shared.m_iStyleSkillAfterRespawn)
			{
				pSkillInfo->SetText((std::string("#DA_SkillInfo_") + SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkillAfterRespawn.Get())).c_str());
				pSkillIcon->SetImage(SkillIDToAlias((SkillID)pPlayer->m_Shared.m_iStyleSkillAfterRespawn.Get()));
			}
			else
			{
				pSkillInfo->SetText("");
				pSkillIcon->SetImage("");
			}
		}
	}

	m_pSuicideOption->SetVisible(pPlayer->IsAlive() && !ShouldShowTeams());

	Button *pProceedButton = dynamic_cast<Button *>(FindChildByName("ProceedButton"));
	if (pProceedButton)
		pProceedButton->SetVisible(m_pPage && FStrEq(m_pPage->GetName(), PANEL_BUY));

	Button *pApproveButton = dynamic_cast<Button *>(FindChildByName("ApproveButton"));
	if (pApproveButton)
		pApproveButton->SetVisible(IsLoadoutComplete());

	Button *pAgentsTab = dynamic_cast<Button *>(FindChildByName("AgentsTab"));
	if (pAgentsTab)
		pAgentsTab->SetVisible(pPlayer->HasCharacterBeenChosen());

	Button *pWeaponsTab = dynamic_cast<Button *>(FindChildByName("WeaponsTab"));
	if (pWeaponsTab)
		pWeaponsTab->SetVisible(pPlayer->HasCharacterBeenChosen());

	Button *pSkillsTab = dynamic_cast<Button *>(FindChildByName("SkillsTab"));
	if (pSkillsTab)
		pSkillsTab->SetVisible(pPlayer->HasSkillsTabBeenSeen());

	Button *pChangeTeams = dynamic_cast<Button *>(FindChildByName("ChangeTeamsButton"));
	if (pChangeTeams)
		pChangeTeams->SetVisible(SDKGameRules()->IsTeamplay());
}
Example #6
0
void GameSettings::UpdateMissionImage()
{	
	vgui::ImagePanel* imgLevelImage = dynamic_cast< vgui::ImagePanel* >( FindChildByName( "ImgLevelImage" ) );
	if( !imgLevelImage )
		return;

	vgui::Label *pMissionLabel = dynamic_cast< vgui::Label* >( FindChildByName( "MissionLabel" ) );


	DropDownMenu *menu = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpSelectMission", true ) );
#if 0
	IASW_Mission_Chooser_Source *pSource = missionchooser ? missionchooser->LocalMissionSource() : NULL;
	if ( !pSource || !m_pSettings || !menu )
		return;

	const char *szGameType = m_pSettings->GetString( "game/mode", "campaign" );
	if ( !Q_stricmp( szGameType, "campaign" ) )
	{
		const char *szCampaign = m_pSettings->GetString( "game/campaign", NULL );
		if ( szCampaign )
		{
			KeyValues *pCampaignKeys = pSource->GetCampaignDetails( szCampaign );
			if ( pCampaignKeys )
			{
				//imgLevelImage->SetImage( pCampaignKeys->GetString( "ChooseCampaignTexture" ) );
				pMissionLabel->SetText( pCampaignKeys->GetString( "CampaignName" ) );
				menu->SetCurrentSelection( pCampaignKeys->GetString( "CampaignName" ) );
			}
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( true );

			const char *szMission = m_pSettings->GetString( "game/mission", NULL );
			if ( szMission )
			{
				KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
				if ( pMissionKeys )
				{
					m_drpStartingMission->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
					imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
				}
			}
		}
	}
	else if ( !Q_stricmp( szGameType, "single_mission" ) )
	{
		const char *szMission = m_pSettings->GetString( "game/mission", NULL );
		if ( szMission )
		{
			KeyValues *pMissionKeys = pSource->GetMissionDetails( szMission );
			if ( pMissionKeys )
			{
				// TODO: Handle missions without an image
				imgLevelImage->SetImage( pMissionKeys->GetString( "image" ) );
				pMissionLabel->SetText( pMissionKeys->GetString( "missiontitle" ) );
				menu->SetCurrentSelection( pMissionKeys->GetString( "missiontitle" ) );
			}
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( false );
		}
	}
#else
	const char *szGameType = m_pSettings->GetString( "game/mode", "sdk" );
	if ( !Q_stricmp( szGameType, "sdk" ) )
	{
		const char *szMission = m_pSettings->GetString( "game/mission", NULL );
		if ( szMission )
		{
			pMissionLabel->SetText( szMission );
			menu->SetCurrentSelection( szMission );
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( false );
		}
	}
	else if( !Q_stricmp( szGameType, "swarmkeeper" ) )
	{
		const char *szMission = m_pSettings->GetString( "game/mission", NULL );
		if ( szMission )
		{
			char path[256];
			Q_snprintf( path, 256, "maps/%s.res", szMission );
			KeyValues *pData = new KeyValues("Data");
			if( pData && pData->LoadFromFile( filesystem, path ) )
			{
				imgLevelImage->SetImage( pData->GetString( "image", "swarm/MissionPics/UnknownMissionPic" ) );
				pMissionLabel->SetText( pData->GetString( "title" ) );
				menu->SetCurrentSelection( pData->GetString( "title" ) );
			}
			else
			{
				imgLevelImage->SetImage( pData->GetString( "image", "swarm/MissionPics/UnknownMissionPic" ) );
				pMissionLabel->SetText( szMission );
				menu->SetCurrentSelection( szMission );
			}

			if( pData ) pData->deleteThis();
		}
		if ( m_drpStartingMission )
		{
			m_drpStartingMission->SetVisible( false );
		}
	}
#endif // 0
}
Example #7
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHL2MPClientScoreBoardDialog::UpdatePlayerInfo()
{
	m_iSectionId = 0; // 0'th row is a header
	int selectedRow = -1;
	int i;

	CBasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();

	if ( !pPlayer || !g_PR )
		return;

	// walk all the players and make sure they're in the scoreboard
	for ( i = 1; i <= gpGlobals->maxClients; i++ )
	{
		bool shouldShow = g_PR->IsConnected( i );
		if ( shouldShow )
		{
			// add the player to the list
			KeyValues *playerData = new KeyValues("data");
			GetPlayerScoreInfo( i, playerData );
			int itemID = FindItemIDForPlayerIndex( i );
  			int sectionID = GetSectionFromTeamNumber( g_PR->GetTeam( i ) );
						
			if (itemID == -1)
			{
				// add a new row
				itemID = m_pPlayerList->AddItem( sectionID, playerData );
			}
			else
			{
				// modify the current row
				m_pPlayerList->ModifyItem( itemID, sectionID, playerData );
			}

			if ( i == pPlayer->entindex() )
			{
				selectedRow = itemID;	// this is the local player, hilight this row
			}

			// set the row color based on the players team
			m_pPlayerList->SetItemFgColor( itemID, g_PR->GetTeamColor( g_PR->GetTeam( i ) ) );

			playerData->deleteThis();
		}
		else
		{
			// remove the player
			int itemID = FindItemIDForPlayerIndex( i );
			if (itemID != -1)
			{
				m_pPlayerList->RemoveItem(itemID);
			}
		}
	}

	if ( selectedRow != -1 )
	{
		m_pPlayerList->SetSelectedItem(selectedRow);
	}

	
}
Example #8
0
//-----------------------------------------------------------------------------
// Purpose: paints all the vgui elements
//-----------------------------------------------------------------------------
void CGameUI::RunFrame()
{
	if ( IsX360() && m_bOpenProgressOnStart )
	{
		StartProgressBar();
		m_bOpenProgressOnStart = false;
	}

	int wide, tall;
#if defined( TOOLFRAMEWORK_VGUI_REFACTOR )
	// resize the background panel to the screen size
	vgui::VPANEL clientDllPanel = enginevguifuncs->GetPanel( PANEL_ROOT );

	int x, y;
	vgui::ipanel()->GetPos( clientDllPanel, x, y );
	vgui::ipanel()->GetSize( clientDllPanel, wide, tall );
	staticPanel->SetBounds( x, y, wide,tall );
#else
	vgui::surface()->GetScreenSize(wide, tall);

	GetUiBaseModPanelClass().SetSize(wide, tall);
#endif

	// Run frames
	g_VModuleLoader.RunFrame();

	GetUiBaseModPanelClass().RunFrame();

	// Play the start-up music the first time we run frame
	if ( IsPC() && m_iPlayGameStartupSound > 0 )
	{
		m_iPlayGameStartupSound--;
		if ( !m_iPlayGameStartupSound )
		{
			PlayGameStartupSound();
		}
	}

	if ( IsPC() && m_bTryingToLoadFriends && m_iFriendsLoadPauseFrames-- < 1 && g_hMutex && g_hWaitMutex )
	{
		// try and load Steam platform files
		unsigned int waitResult = Sys_WaitForSingleObject(g_hMutex, 0);
		if (waitResult == SYS_WAIT_OBJECT_0 || waitResult == SYS_WAIT_ABANDONED)
		{
			// we got the mutex, so load Friends/Serverbrowser
			// clear the loading flag
			m_bTryingToLoadFriends = false;
			g_VModuleLoader.LoadPlatformModules(&m_GameFactory, 1, false);

			// release the wait mutex
			Sys_ReleaseMutex(g_hWaitMutex);

			// notify the game of our game name
			const char *fullGamePath = engine->GetGameDirectory();
			const char *pathSep = strrchr( fullGamePath, '/' );
			if ( !pathSep )
			{
				pathSep = strrchr( fullGamePath, '\\' );
			}
			if ( pathSep )
			{
				KeyValues *pKV = new KeyValues("ActiveGameName" );
				pKV->SetString( "name", pathSep + 1 );
				pKV->SetInt( "appid", engine->GetAppID() );
				KeyValues *modinfo = new KeyValues("ModInfo");
				if ( modinfo->LoadFromFile( g_pFullFileSystem, "gameinfo.txt" ) )
				{
					pKV->SetString( "game", modinfo->GetString( "game", "" ) );
				}
				modinfo->deleteThis();
				
				g_VModuleLoader.PostMessageToAllModules( pKV );
			}

			// notify the ui of a game connect if we're already in a game
			if (m_iGameIP)
			{
				SendConnectedToGameMessage();
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void COptionsSubKeyboard::ParseActionDescriptions( void )
{
	char szBinding[256];
	char szDescription[256];

	KeyValues *item;

	// Load the default keys list
	CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
	if ( !g_pFullFileSystem->ReadFile( "scripts/kb_act.lst", NULL, buf ) )
		return;

	const char *data = (const char*)buf.Base();

	int sectionIndex = 0;
	char token[512];
	while ( 1 )
	{
		data = UTIL_Parse( data, token, sizeof(token) );
		// Done.
		if ( strlen( token ) <= 0 )  
			break;

		Q_strncpy( szBinding, token, sizeof( szBinding ) );

		data = UTIL_Parse( data, token, sizeof(token) );
		if ( strlen(token) <= 0 )
		{
			break;
		}

		Q_strncpy(szDescription, token, sizeof( szDescription ) );

		// Skip '======' rows
		if ( szDescription[ 0 ] != '=' )
		{
			// Flag as special header row if binding is "blank"
			if (!stricmp(szBinding, "blank"))
			{
				// add header item
				int nColumn1 = 286;
				int nColumn2 = 128;
				if ( IsProportional() )
				{
					nColumn1 = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), nColumn1 );
					nColumn2 = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), nColumn2 );
				}
				m_pKeyBindList->AddSection(++sectionIndex, szDescription);
				m_pKeyBindList->AddColumnToSection(sectionIndex, "Action", szDescription, SectionedListPanel::COLUMN_BRIGHT, nColumn1 );
				m_pKeyBindList->AddColumnToSection(sectionIndex, "Key", "#GameUI_KeyButton", SectionedListPanel::COLUMN_BRIGHT, nColumn2 );
			}
			else
			{
				// Create a new: blank item
				item = new KeyValues( "Item" );
				
				// fill in data
				item->SetString("Action", szDescription);
				item->SetString("Binding", szBinding);
				item->SetString("Key", "");

				// Add to list
				m_pKeyBindList->AddItem(sectionIndex, item);
				item->deleteThis();
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *filename - 
//-----------------------------------------------------------------------------
void CDecalEmitterSystem::LoadDecalsFromScript( char const *filename )
{
	KeyValues *kv = new KeyValues( filename );
	Assert( kv );
	if ( kv )
	{
		KeyValues *translation = NULL;
#ifndef _XBOX
		if ( kv->LoadFromFile( filesystem, filename ) )
#else
		if ( kv->LoadFromFile( filesystem, filename, "GAME" ) )
#endif
		{
			KeyValues *p = kv;
			while ( p )
			{
				if ( p->GetFirstSubKey() )
				{
					char const *keyname = p->GetName();

					if ( !Q_stricmp( keyname, TRANSLATION_DATA_SECTION ) )
					{
						translation = p;
					}
					else
					{
						DecalEntry entry;

						for ( KeyValues *sub = p->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
						{
							MEM_ALLOC_CREDIT();

							DecalListEntry decal;
							decal.precache_index = -1;
							decal.name = m_DecalFileNames.AddString( sub->GetName() );
							decal.weight = sub->GetFloat();

							// Add to global list
							int idx = m_AllDecals.AddToTail( decal );

							// Add index only to local list
							entry.indices.AddToTail( idx );
						}

						// Add entry to main dictionary
						m_Decals.Insert( keyname, entry );
					}
				}
				p = p->GetNextKey();
			}
		}
		else
		{
			Msg( "CDecalEmitterSystem::LoadDecalsFromScript:  Unable to load '%s'\n", filename );
		}

		if ( !translation )
		{
			Msg( "CDecalEmitterSystem::LoadDecalsFromScript:  Script '%s' missing section '%s'\n",
				filename,
				TRANSLATION_DATA_SECTION );
		}
		else
		{
			// Now parse game material to entry translation table
			for ( KeyValues *sub = translation->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
			{
				// Don't add NULL string to list
				if ( !Q_stricmp( sub->GetString(), "" ) )
					continue;

				int idx = m_Decals.Find( sub->GetString() );
				if ( idx != m_Decals.InvalidIndex() )
				{
					m_GameMaterialTranslation.Insert( sub->GetName(), idx );
				}
				else
				{
					Msg( "CDecalEmitterSystem::LoadDecalsFromScript:  Translation for game material type '%s' references unknown decal '%s'\n",
						sub->GetName(), sub->GetString() );
				}
			}
		}

		kv->deleteThis();
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CClientScoreBoardDialog::UpdatePlayerInfo()
{
	m_iSectionId = 0; // 0'th row is a header
	int selectedRow = -1;

	// walk all the players and make sure they're in the scoreboard
	for ( int i = 1; i <= gpGlobals->maxClients; ++i )
	{
		IGameResources *gr = GameResources();

		if ( gr && gr->IsConnected( i ) )
		{
			// add the player to the list
			KeyValues *playerData = new KeyValues("data");
			GetPlayerScoreInfo( i, playerData );
			UpdatePlayerAvatar( i, playerData );

			const char *oldName = playerData->GetString("name","");
			int bufsize = strlen(oldName) * 2 + 1;
			char *newName = (char *)_alloca( bufsize );

			UTIL_MakeSafeName( oldName, newName, bufsize );

			playerData->SetString("name", newName);

			int itemID = FindItemIDForPlayerIndex( i );
  			int sectionID = gr->GetTeam( i );
			
			if ( gr->IsLocalPlayer( i ) )
			{
				selectedRow = itemID;
			}
			if (itemID == -1)
			{
				// add a new row
				itemID = m_pPlayerList->AddItem( sectionID, playerData );
			}
			else
			{
				// modify the current row
				m_pPlayerList->ModifyItem( itemID, sectionID, playerData );
			}

			// set the row color based on the players team
			m_pPlayerList->SetItemFgColor( itemID, gr->GetTeamColor( sectionID ) );

			playerData->deleteThis();
		}
		else
		{
			// remove the player
			int itemID = FindItemIDForPlayerIndex( i );
			if (itemID != -1)
			{
				m_pPlayerList->RemoveItem(itemID);
			}
		}
	}

	if ( selectedRow != -1 )
	{
		m_pPlayerList->SetSelectedItem(selectedRow);
	}
}
//-----------------------------------------------------------------------------
// Purpose: Do the headlight
//-----------------------------------------------------------------------------
void CFlashlightEffect::UpdateLightNew(const Vector &vecPos, const Vector &vecForward, const Vector &vecRight, const Vector &vecUp )
{
	VPROF_BUDGET( "CFlashlightEffect::UpdateLightNew", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );

	FlashlightState_t state;

	// We will lock some of the flashlight params if player is on a ladder, to prevent oscillations due to the trace-rays
	bool bPlayerOnLadder = ( C_BasePlayer::GetLocalPlayer()->GetMoveType() == MOVETYPE_LADDER );

	const float flEpsilon = 0.1f;			// Offset flashlight position along vecUp
	const float flDistCutoff = 128.0f;
	const float flDistDrag = 0.2;

	CTraceFilterSkipPlayerAndViewModel traceFilter;
	float flOffsetY = r_flashlightoffsety.GetFloat();

	if( r_swingflashlight.GetBool() )
	{
		// This projects the view direction backwards, attempting to raise the vertical
		// offset of the flashlight, but only when the player is looking down.
		Vector vecSwingLight = vecPos + vecForward * -12.0f;
		if( vecSwingLight.z > vecPos.z )
		{
			flOffsetY += (vecSwingLight.z - vecPos.z);
		}
	}

	Vector vOrigin = vecPos + flOffsetY * vecUp;

	// Not on ladder...trace a hull
	if ( !bPlayerOnLadder ) 
	{
		trace_t pmOriginTrace;
		UTIL_TraceHull( vecPos, vOrigin, Vector(-4, -4, -4), Vector(4, 4, 4), MASK_SOLID & ~(CONTENTS_HITBOX), &traceFilter, &pmOriginTrace );

		if ( pmOriginTrace.DidHit() )
		{
			vOrigin = vecPos;
		}
	}
	else // on ladder...skip the above hull trace
	{
		vOrigin = vecPos;
	}

	// Now do a trace along the flashlight direction to ensure there is nothing within range to pull back from
	int iMask = MASK_OPAQUE_AND_NPCS;
	iMask &= ~CONTENTS_HITBOX;
	iMask |= CONTENTS_WINDOW;

	Vector vTarget = vecPos + vecForward * r_flashlightfar.GetFloat();

	// Work with these local copies of the basis for the rest of the function
	Vector vDir   = vTarget - vOrigin;
	Vector vRight = vecRight;
	Vector vUp    = vecUp;
	VectorNormalize( vDir   );
	VectorNormalize( vRight );
	VectorNormalize( vUp    );

	// Orthonormalize the basis, since the flashlight texture projection will require this later...
	vUp -= DotProduct( vDir, vUp ) * vDir;
	VectorNormalize( vUp );
	vRight -= DotProduct( vDir, vRight ) * vDir;
	VectorNormalize( vRight );
	vRight -= DotProduct( vUp, vRight ) * vUp;
	VectorNormalize( vRight );

	AssertFloatEquals( DotProduct( vDir, vRight ), 0.0f, 1e-3 );
	AssertFloatEquals( DotProduct( vDir, vUp    ), 0.0f, 1e-3 );
	AssertFloatEquals( DotProduct( vRight, vUp  ), 0.0f, 1e-3 );

	trace_t pmDirectionTrace;
	UTIL_TraceHull( vOrigin, vTarget, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ), iMask, &traceFilter, &pmDirectionTrace );

	if ( r_flashlightvisualizetrace.GetBool() == true )
	{
		debugoverlay->AddBoxOverlay( pmDirectionTrace.endpos, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ), QAngle( 0, 0, 0 ), 0, 0, 255, 16, 0 );
		debugoverlay->AddLineOverlay( vOrigin, pmDirectionTrace.endpos, 255, 0, 0, false, 0 );
	}

	float flDist = (pmDirectionTrace.endpos - vOrigin).Length();
	if ( flDist < flDistCutoff )
	{
		// We have an intersection with our cutoff range
		// Determine how far to pull back, then trace to see if we are clear
		float flPullBackDist = bPlayerOnLadder ? r_flashlightladderdist.GetFloat() : flDistCutoff - flDist;	// Fixed pull-back distance if on ladder
		m_flDistMod = Lerp( flDistDrag, m_flDistMod, flPullBackDist );
		
		if ( !bPlayerOnLadder )
		{
			trace_t pmBackTrace;
			UTIL_TraceHull( vOrigin, vOrigin - vDir*(flPullBackDist-flEpsilon), Vector( -4, -4, -4 ), Vector( 4, 4, 4 ), iMask, &traceFilter, &pmBackTrace );
			if( pmBackTrace.DidHit() )
			{
				// We have an intersection behind us as well, so limit our m_flDistMod
				float flMaxDist = (pmBackTrace.endpos - vOrigin).Length() - flEpsilon;
				if( m_flDistMod > flMaxDist )
					m_flDistMod = flMaxDist;
			}
		}
	}
	else
	{
		m_flDistMod = Lerp( flDistDrag, m_flDistMod, 0.0f );
	}
	vOrigin = vOrigin - vDir * m_flDistMod;

	state.m_vecLightOrigin = vOrigin;

	BasisToQuaternion( vDir, vRight, vUp, state.m_quatOrientation );

	state.m_fQuadraticAtten = r_flashlightquadratic.GetFloat();

	bool bFlicker = false;

#ifdef HL2_EPISODIC
	C_BaseHLPlayer *pPlayer = (C_BaseHLPlayer *)C_BasePlayer::GetLocalPlayer();
	if ( pPlayer )
	{
		float flBatteryPower = ( pPlayer->m_HL2Local.m_flFlashBattery >= 0.0f ) ? ( pPlayer->m_HL2Local.m_flFlashBattery ) : pPlayer->m_HL2Local.m_flSuitPower;
		if ( flBatteryPower <= 10.0f )
		{
			float flScale;
			if ( flBatteryPower >= 0.0f )
			{	
				flScale = ( flBatteryPower <= 4.5f ) ? SimpleSplineRemapVal( flBatteryPower, 4.5f, 0.0f, 1.0f, 0.0f ) : 1.0f;
			}
			else
			{
				flScale = SimpleSplineRemapVal( flBatteryPower, 10.0f, 4.8f, 1.0f, 0.0f );
			}
			
			flScale = clamp( flScale, 0.0f, 1.0f );

			if ( flScale < 0.35f )
			{
				float flFlicker = cosf( gpGlobals->curtime * 6.0f ) * sinf( gpGlobals->curtime * 15.0f );
				
				if ( flFlicker > 0.25f && flFlicker < 0.75f )
				{
					// On
					state.m_fLinearAtten = r_flashlightlinear.GetFloat() * flScale;
				}
				else
				{
					// Off
					state.m_fLinearAtten = 0.0f;
				}
			}
			else
			{
				float flNoise = cosf( gpGlobals->curtime * 7.0f ) * sinf( gpGlobals->curtime * 25.0f );
				state.m_fLinearAtten = r_flashlightlinear.GetFloat() * flScale + 1.5f * flNoise;
			}

			state.m_fHorizontalFOVDegrees = r_flashlightfov.GetFloat() - ( 16.0f * (1.0f-flScale) );
			state.m_fVerticalFOVDegrees = r_flashlightfov.GetFloat() - ( 16.0f * (1.0f-flScale) );
			
			bFlicker = true;
		}
	}
#endif // HL2_EPISODIC

	if ( bFlicker == false )
	{
		state.m_fLinearAtten = r_flashlightlinear.GetFloat();
		state.m_fHorizontalFOVDegrees = r_flashlightfov.GetFloat();
		state.m_fVerticalFOVDegrees = r_flashlightfov.GetFloat();
	}

	state.m_fConstantAtten = r_flashlightconstant.GetFloat();
	state.m_Color[0] = 1.0f;
	state.m_Color[1] = 1.0f;
	state.m_Color[2] = 1.0f;
	state.m_Color[3] = r_flashlightambient.GetFloat();
	state.m_NearZ = r_flashlightnear.GetFloat() + m_flDistMod;	// Push near plane out so that we don't clip the world when the flashlight pulls back 
	state.m_FarZ = r_flashlightfar.GetFloat();
	state.m_bEnableShadows = r_flashlightdepthtexture.GetBool();
	state.m_flShadowMapResolution = r_flashlightdepthres.GetInt();

	state.m_pSpotlightTexture = m_FlashlightTexture;
	state.m_nSpotlightTextureFrame = 0;

	state.m_flShadowAtten = r_flashlightshadowatten.GetFloat();
	state.m_flShadowSlopeScaleDepthBias = mat_slopescaledepthbias_shadowmap.GetFloat();
	state.m_flShadowDepthBias = mat_depthbias_shadowmap.GetFloat();

	if( m_FlashlightHandle == CLIENTSHADOW_INVALID_HANDLE )
	{
		m_FlashlightHandle = g_pClientShadowMgr->CreateFlashlight( state );
	}
	else
	{
		if( !r_flashlightlockposition.GetBool() )
		{
			g_pClientShadowMgr->UpdateFlashlightState( m_FlashlightHandle, state );
		}
	}
	
	g_pClientShadowMgr->UpdateProjectedTexture( m_FlashlightHandle, true );
	
	// Kill the old flashlight method if we have one.
	LightOffOld();

#ifndef NO_TOOLFRAMEWORK
	if ( clienttools->IsInRecordingMode() )
	{
		KeyValues *msg = new KeyValues( "FlashlightState" );
		msg->SetFloat( "time", gpGlobals->curtime );
		msg->SetInt( "entindex", m_nEntIndex );
		msg->SetInt( "flashlightHandle", m_FlashlightHandle );
		msg->SetPtr( "flashlightState", &state );
		ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
		msg->deleteThis();
	}
#endif
}
Example #13
0
bool CEngineSprite::Init( const char *pName )
{
	m_VideoMaterial = NULL;
	for ( int i = 0; i < kRenderModeCount; ++i )
	{
		m_material[ i ] = NULL;
	}

	m_width = m_height = m_numFrames = 1;

	Assert( g_pVideo != NULL );
	
	if ( g_pVideo != NULL && g_pVideo->LocateVideoSystemForPlayingFile( pName ) != VideoSystem::NONE ) 
	{
		m_VideoMaterial = g_pVideo->CreateVideoMaterial( pName, pName, "GAME", VideoPlaybackFlags::DEFAULT_MATERIAL_OPTIONS, VideoSystem::DETERMINE_FROM_FILE_EXTENSION, false ); 
		
		if ( m_VideoMaterial == NULL )
			return false;

		IMaterial *pMaterial = m_VideoMaterial->GetMaterial();
		m_VideoMaterial->GetVideoImageSize( &m_width, &m_height );
		m_numFrames = m_VideoMaterial->GetFrameCount();
		for ( int i = 0; i < kRenderModeCount; ++i )
		{
			m_material[i] = pMaterial;
			pMaterial->IncrementReferenceCount();
		}
	}
	else
	{
		char pTemp[MAX_PATH];
		char pMaterialName[MAX_PATH];
		char pMaterialPath[MAX_PATH];
		Q_StripExtension( pName, pTemp, sizeof(pTemp) );
		Q_strlower( pTemp );
		Q_FixSlashes( pTemp, '/' );

		// Check to see if this is a UNC-specified material name
		bool bIsUNC = pTemp[0] == '/' && pTemp[1] == '/' && pTemp[2] != '/';
		if ( !bIsUNC )
		{
			Q_strncpy( pMaterialName, "materials/", sizeof(pMaterialName) );
			Q_strncat( pMaterialName, pTemp, sizeof(pMaterialName), COPY_ALL_CHARACTERS );
		}
		else
		{
			Q_strncpy( pMaterialName, pTemp, sizeof(pMaterialName) );
		}
		Q_strncpy( pMaterialPath, pMaterialName, sizeof(pMaterialPath) );
		Q_SetExtension( pMaterialPath, ".vmt", sizeof(pMaterialPath) );

		KeyValues *kv = new KeyValues( "vmt" );
		if ( !kv->LoadFromFile( g_pFullFileSystem, pMaterialPath, "GAME" ) )
		{
			Warning( "Unable to load sprite material %s!\n", pMaterialPath );
			return false;
		}

		for ( int i = 0; i < kRenderModeCount; ++i )
		{	
			if ( i == kRenderNone || i == kRenderEnvironmental )
			{
				m_material[i] = NULL;
				continue;
			}

			Q_snprintf( pMaterialPath, sizeof(pMaterialPath), "%s_rendermode_%d", pMaterialName, i );
			KeyValues *pMaterialKV = kv->MakeCopy();
			pMaterialKV->SetInt( "$spriteRenderMode", i );
			m_material[i] = g_pMaterialSystem->FindProceduralMaterial( pMaterialPath, TEXTURE_GROUP_CLIENT_EFFECTS, pMaterialKV );
			m_material[ i ]->IncrementReferenceCount();
		}

		kv->deleteThis();

		m_width = m_material[0]->GetMappingWidth();
		m_height = m_material[0]->GetMappingHeight();
		m_numFrames = m_material[0]->GetNumAnimationFrames();
	}

	for ( int i = 0; i < kRenderModeCount; ++i )
	{
		if ( i == kRenderNone || i == kRenderEnvironmental )
			continue;

		if ( !m_material[i] )
			return false;
	}

	IMaterialVar *orientationVar = m_material[0]->FindVarFast( "$spriteorientation", &spriteOrientationCache );
	m_orientation = orientationVar ? orientationVar->GetIntValue() : C_SpriteRenderer::SPR_VP_PARALLEL_UPRIGHT;

	IMaterialVar *originVar = m_material[0]->FindVarFast( "$spriteorigin", &spriteOriginCache );
	Vector origin, originVarValue;
	if( !originVar || ( originVar->GetType() != MATERIAL_VAR_TYPE_VECTOR ) )
	{
		origin[0] = -m_width * 0.5f;
		origin[1] = m_height * 0.5f;
	}
	else
	{
		originVar->GetVecValue( &originVarValue[0], 3 );
		origin[0] = -m_width * originVarValue[0];
		origin[1] = m_height * originVarValue[1];
	}

	up = origin[1];
	down = origin[1] - m_height;
	left = origin[0];
	right = m_width + origin[0];

	return true;
}
void CKeyBindingHelpDialog::PopulateList()
{
	m_pList->DeleteAllItems();

	int i, j;

	CUtlVector< ListInfo_t > maps;
	vgui2::Panel *pPanel = m_hPanel;
	while ( pPanel->IsKeyBindingChainToParentAllowed() )
	{
		PanelKeyBindingMap *map = pPanel->GetKBMap();
		while ( map )
		{
			int k;
			int c = maps.Count();
			for ( k = 0; k < c; ++k )
			{
				if ( maps[k].m_pMap == map )
					break;
			}
			if ( k == c )
			{
				int mapIndex = maps.AddToTail( );
				maps[mapIndex].m_pMap = map;
				maps[mapIndex].m_pPanel = pPanel;
			}
			map = map->baseMap;
		}

		pPanel = pPanel->GetParent();
		if ( !pPanel )
			break;
	}

	CUtlRBTree< KeyValues *, int >	sorted( 0, 0, BindingLessFunc );

	// add header item
	int c = maps.Count();
	for ( i = 0; i < c; ++i )
	{
		PanelKeyBindingMap *m = maps[ i ].m_pMap;
		Panel *pMapPanel = maps[i].m_pPanel;
		Assert( m );

		int bindings = m->boundkeys.Count();
		for ( j = 0; j < bindings; ++j )
		{
			BoundKey_t *kbMap = &m->boundkeys[ j ];
			Assert( kbMap );

			// Create a new: blank item
			KeyValues *item = new KeyValues( "Item" );
			
			// Fill in data
			char loc[ 128 ];
			Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname );

			char ansi[ 256 ];
			AnsiText( loc, ansi, sizeof( ansi ) );

			item->SetString( "Action", ansi );
			item->SetWString( "Binding", Panel::KeyCodeModifiersToDisplayString( (KeyCode)kbMap->keycode, kbMap->modifiers ) );

			// Find the binding
			KeyBindingMap_t *bindingMap = pMapPanel->LookupBinding( kbMap->bindingname );
			if ( bindingMap && 
				 bindingMap->helpstring )
			{
				AnsiText( bindingMap->helpstring, ansi, sizeof( ansi ) );
				item->SetString( "Description", ansi );
			}
			
			item->SetPtr( "Item", kbMap );			

			sorted.Insert( item );
		}

		// Now try and find any "unbound" keys...
		int mappings = m->entries.Count();
		for ( j = 0; j < mappings; ++j )
		{
			KeyBindingMap_t *kbMap = &m->entries[ j ];

			// See if it's bound
			CUtlVector< BoundKey_t * > list;
			pMapPanel->LookupBoundKeys( kbMap->bindingname, list );
			if ( list.Count() > 0 )
				continue;

			// Not bound, add a placeholder entry
			// Create a new: blank item
			KeyValues *item = new KeyValues( "Item" );
			
			// fill in data
			char loc[ 128 ];
			Q_snprintf( loc, sizeof( loc ), "#%s", kbMap->bindingname );

			char ansi[ 256 ];
			AnsiText( loc, ansi, sizeof( ansi ) );

			item->SetString( "Action", ansi );
			item->SetWString( "Binding", L"" );
			if ( kbMap->helpstring )
			{
				AnsiText( kbMap->helpstring, ansi, sizeof( ansi ) );
				item->SetString( "Description", ansi );
			}

			item->SetPtr( "Unbound", kbMap );						

			sorted.Insert( item );
		}
	}

	for ( j = sorted.FirstInorder() ; j != sorted.InvalidIndex(); j = sorted.NextInorder( j ) )
	{
		KeyValues *item = sorted[ j ];

		// Add to list
		m_pList->AddItem( item, 0, false, false );

		item->deleteThis();
	}

	sorted.RemoveAll();
}
Example #15
0
//-----------------------------------------------------------------------------
// Purpose: This is called every time the DLL is loaded
//-----------------------------------------------------------------------------
void CHud::Init( void )
{
	HOOK_HUD_MESSAGE( gHUD, ResetHUD );
	
#ifdef CSTRIKE_DLL
	HOOK_HUD_MESSAGE( gHUD, SendAudio );
#endif

	InitFonts();

	// Create all the Hud elements
	CHudElementHelper::CreateAllElements();

	gLCD.Init();

	// Initialize all created elements
	for ( int i = 0; i < m_HudList.Size(); i++ )
	{
		m_HudList[i]->Init();
	}

	m_bHudTexturesLoaded = false;

	KeyValues *kv = new KeyValues( "layout" );
	if ( kv )
	{
		if ( kv->LoadFromFile( filesystem, "scripts/HudLayout.res" ) )
		{
			int numelements = m_HudList.Size();

			for ( int i = 0; i < numelements; i++ )
			{
				CHudElement *element = m_HudList[i];

				vgui::Panel *pPanel = dynamic_cast<vgui::Panel*>(element);
				if ( !pPanel )
				{
					Msg( "Non-vgui hud element %s\n", m_HudList[i]->GetName() );
					continue;
				}

				KeyValues *key = kv->FindKey( pPanel->GetName(), false );
				if ( !key )
				{
					Msg( "Hud element '%s' doesn't have an entry '%s' in scripts/HudLayout.res\n", m_HudList[i]->GetName(), pPanel->GetName() );
				}

				// Note:  When a panel is parented to the module root, it's "parent" is returned as NULL.
				if ( !element->IsParentedToClientDLLRootPanel() && 
					 !pPanel->GetParent() )
				{
					DevMsg( "Hud element '%s'/'%s' doesn't have a parent\n", m_HudList[i]->GetName(), pPanel->GetName() );
				}
			}
		}

		kv->deleteThis();
	}

	if ( m_bHudTexturesLoaded )
		return;

	m_bHudTexturesLoaded = true;
	CUtlDict< CHudTexture *, int >	textureList;

	// check to see if we have sprites for this res; if not, step down
	LoadHudTextures( textureList, "scripts/hud_textures", NULL );
	LoadHudTextures( textureList, "scripts/mod_textures", NULL );

	int c = textureList.Count();
	for ( int index = 0; index < c; index++ )
	{
		CHudTexture* tex = textureList[ index ];
		AddSearchableHudIconToList( *tex );
	}

	FreeHudTextureList( textureList );
}
Example #16
0
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();
    }
}
Example #17
0
void LoadHudTextures( CUtlDict< CHudTexture *, int >& list, const char *szFilenameWithoutExtension, const unsigned char *pICEKey )
{
	KeyValues *pTemp, *pTextureSection;

	KeyValues *pKeyValuesData = ReadEncryptedKVFile( filesystem, szFilenameWithoutExtension, pICEKey );
	if ( pKeyValuesData )
	{
		CUtlVector<HudTextureFileRef> hudTextureFileRefs;

		// By default, add a default entry mapping "file" to no prefix. This will allow earlier-version files
		// to work with no modification.
		hudTextureFileRefs.AddToTail( HudTextureFileRef( "file", "" ) );

		// Read "*file"-to-prefix mapping.
		KeyValues *pTextureFileRefs = pKeyValuesData->FindKey( "TextureFileRefs" );
		if ( pTextureFileRefs )
		{
			pTemp = pTextureFileRefs->GetFirstSubKey();
			while ( pTemp )
			{
				hudTextureFileRefs.AddToTail( HudTextureFileRef( pTemp->GetName(), pTemp->GetString( "prefix", "" ) ) );
				pTemp = pTemp->GetNextKey();
			}
		}

		// Read our individual HUD texture data blocks.
		pTextureSection = pKeyValuesData->FindKey( "TextureData" );
		if ( pTextureSection  )
		{
			// Read the sprite data
			pTemp = pTextureSection->GetFirstSubKey();
			while ( pTemp )
			{
				if ( pTemp->GetString( "font", NULL ) )
				{
					CHudTexture *tex = new CHudTexture();

					// Key Name is the sprite name
					Q_strncpy( tex->szShortName, pTemp->GetName(), sizeof( tex->szShortName ) );

					// it's a font-based icon
					tex->bRenderUsingFont = true;
					tex->cCharacterInFont = *(pTemp->GetString("character", ""));
					Q_strncpy( tex->szTextureFile, pTemp->GetString( "font" ), sizeof( tex->szTextureFile ) );

					list.Insert( tex->szShortName, tex );
				}
				else
				{
					int iTexLeft	= pTemp->GetInt( "x", 0 ),
						iTexTop		= pTemp->GetInt( "y", 0 ),
						iTexRight	= pTemp->GetInt( "width", 0 )	+ iTexLeft,
						iTexBottom	= pTemp->GetInt( "height", 0 )	+ iTexTop;

					for ( int i = 0; i < hudTextureFileRefs.Size(); i++ )
					{
						const char *cszFilename = pTemp->GetString( hudTextureFileRefs[i].m_fileKeySymbol, NULL );
						if ( cszFilename )
						{
							CHudTexture *tex = new CHudTexture();

							tex->bRenderUsingFont = false;
							tex->rc.left	= iTexLeft;
							tex->rc.top		= iTexTop;
							tex->rc.right	= iTexRight;
							tex->rc.bottom	= iTexBottom;

							Q_strncpy( tex->szShortName, hudTextureFileRefs[i].m_cszHudTexturePrefix, sizeof( tex->szShortName ) );
							Q_strncpy( tex->szShortName + hudTextureFileRefs[i].m_uiPrefixLength, pTemp->GetName(), sizeof( tex->szShortName ) - hudTextureFileRefs[i].m_uiPrefixLength );
							Q_strncpy( tex->szTextureFile, cszFilename, sizeof( tex->szTextureFile ) );

							list.Insert( tex->szShortName, tex );
						}
					}
				}

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

	// Failed for some reason. Delete the Key data and abort.
	pKeyValuesData->deleteThis();
}
Example #18
0
bool CMapzoneData::LoadFromFile(const char *szMapName)
{
    bool toReturn = false;
    char zoneFilePath[MAX_PATH];
    Q_strcpy(zoneFilePath, c_mapPath);
    Q_strcat(zoneFilePath, szMapName, MAX_PATH);
    Q_strncat(zoneFilePath, c_zoneFileEnding, MAX_PATH);
    DevLog("Looking for zone file: %s \n", zoneFilePath);
    KeyValues* zoneKV = new KeyValues(szMapName);
    if (zoneKV->LoadFromFile(filesystem, zoneFilePath, "MOD"))
    {
        // Go through checkpoints
        for (KeyValues *cp = zoneKV->GetFirstSubKey(); cp; cp = cp->GetNextKey())
        {
            // Load position information (will default to 0 if the keys don't exist)
            Vector* pos = new Vector(cp->GetFloat("xPos"), cp->GetFloat("yPos"), cp->GetFloat("zPos"));
            QAngle* rot = new QAngle(cp->GetFloat("xRot"), cp->GetFloat("yRot"), cp->GetFloat("zRot"));
            Vector* scaleMins = new Vector(cp->GetFloat("xScaleMins"), cp->GetFloat("yScaleMins"), cp->GetFloat("zScaleMins"));
            Vector* scaleMaxs = new Vector(cp->GetFloat("xScaleMaxs"), cp->GetFloat("yScaleMaxs"), cp->GetFloat("zScaleMaxs"));

            // Do specific things for different types of checkpoints
            // 0 = start, 1 = checkpoint, 2 = end, 3 = Onehop, 4 = OnehopReset, 5 = Checkpoint_teleport, 6 = Multihop, 7 = stage
            int zoneType = -1;
            int index = -1;
            bool shouldStop = false;
            bool shouldTilt = true;
            float holdTime = 1.0f;
            //int destinationIndex = -1;
            bool limitingspeed = true;
            float maxleavespeed = 290.0f;
            const char * linkedtrigger = NULL;

            if (Q_strcmp(cp->GetName(), "start") == 0)
            {
                zoneType = MOMZONETYPE_START;
                limitingspeed = cp->GetBool("limitingspeed");
                maxleavespeed = cp->GetFloat("leavespeed");
            }
            else if (Q_strcmp(cp->GetName(), "checkpoint") == 0)
            {
                zoneType = MOMZONETYPE_CP;
                index = cp->GetInt("number", -1);
            }
            else if (Q_strcmp(cp->GetName(), "end") == 0)
            {
                zoneType = MOMZONETYPE_STOP;
            }
            else if (Q_strcmp(cp->GetName(), "onehop") == 0)
            {
                zoneType = MOMZONETYPE_ONEHOP;
                shouldStop = cp->GetBool("stop", false);
                shouldTilt = cp->GetBool("resetang", true);
                holdTime = cp->GetFloat("hold", 1);
                //destinationIndex = cp->GetInt("destination", 1);
                linkedtrigger = cp->GetString("destinationname", NULL);
            }
            else if (Q_strcmp(cp->GetName(), "resetonehop") == 0)
            {
                zoneType = MOMZONETYPE_RESETONEHOP;
            }
            else if (Q_strcmp(cp->GetName(), "checkpoint_teleport") == 0)
            {
                zoneType = MOMZONETYPE_CPTELE;
                //destinationIndex = cp->GetInt("destination", -1);
                shouldStop = cp->GetBool("stop", false);
                shouldTilt = cp->GetBool("resetang", true);
                linkedtrigger = cp->GetString("destinationname", NULL);
            }
            else if (Q_strcmp(cp->GetName(), "multihop") == 0)
            {
                zoneType = MOMZONETYPE_MULTIHOP;
                shouldStop = cp->GetBool("stop", false);
                shouldTilt = cp->GetBool("resetang", true);
                holdTime = cp->GetFloat("hold", 1);
                //destinationIndex = cp->GetInt("destination", 1);
                linkedtrigger = cp->GetString("destinationname", NULL);
            }
            else if (Q_strcmp(cp->GetName(), "stage") == 0)
            {
                zoneType = MOMZONETYPE_STAGE;
                index = cp->GetInt("number", 0);
            }
            else
            {
                Warning("Error while reading zone file: Unknown mapzone type %s!\n", cp->GetName());
                continue;
            }

            // Add element
            m_zones.AddToTail(new CMapzone(zoneType, pos, rot, scaleMins, scaleMaxs, index, shouldStop, shouldTilt,
                holdTime, limitingspeed, maxleavespeed, MAKE_STRING(linkedtrigger)));
        }
        DevLog("Successfully loaded map zone file %s!\n", zoneFilePath);
        toReturn = true;
    }
    zoneKV->deleteThis();
    return toReturn;
}
void CreateDirectoryStrings()
{
    DestroyDirectoryStrings();

    char _wdTmp[ MASTERPATH_MAXLEN ];
    char szSearchPath[ MASTERPATH_MAXLEN ];

    if ( g_pFullFileSystem->GetSearchPath( "EXECUTABLE_PATH", false, szSearchPath, sizeof( szSearchPath ) ) > 0 )
    {
        Q_strncpy( _wdTmp, szSearchPath, MASTERPATH_MAXLEN );
    }
    else
    {
        *szSearchPath = 0;

        if ( !g_pFullFileSystem->GetCurrentDirectory( _wdTmp, MASTERPATH_MAXLEN  ) )
            getcwd( _wdTmp, sizeof( _wdTmp ) );
    }

    Q_FixSlashes( _wdTmp );

    Q_strncpy( _wd, _wdTmp, MASTERPATH_MAXLEN );

    char *sapps = Q_stristr( _wdTmp, "steamapps" );

    if ( sapps )
    {
        sapps = Q_StripFirstDir( sapps );
        Q_IsolateFirstDir( sapps );
        Q_snprintf( _acc, MASTERPATH_MAXLEN, "%s", sapps );

        *sapps = '\0';
    }
    else
    {
        Warning( "Unable to find account name/common\n" );
        Q_snprintf( _acc, MASTERPATH_MAXLEN, "common" );
    }

    //char *smods = Q_stristr( _wdTmp, "SourceMods" );
    const char *_game = engine->GetGameDirectory();

    Q_snprintf( _gamePath, MASTERPATH_MAXLEN, "%s", _game );
    Q_FixSlashes( _gamePath );

    KeyValues *pKV = new KeyValues("cfg");
    const char *localize = "..\\..\\..\\..\\";

#ifdef SHADER_EDITOR_DLL_SWARM
    const char *defCMP = "alien swarm/bin";
    const char *defCMPKey = "compiler_swarm";
#elif SHADER_EDITOR_DLL_2006
    const char *defCMP = "sourcesdk/bin/ep1/bin";
    const char *defCMPKey = "compiler_2006";
#elif SHADER_EDITOR_DLL_2013
    const char *defCMP = "";
    const char *defCMPKey = "compiler_2013";
#else
    const char *defCMP = "sourcesdk/bin/source2007/bin";
    const char *defCMPKey = "compiler";
#endif

    const char *_cmp = defCMP;
    if ( pKV->LoadFromFile( g_pFullFileSystem, "shadereditorui/path_config.txt", "MOD" ) )
        _cmp = pKV->GetString( defCMPKey, defCMP );

#ifdef SHADER_EDITOR_DLL_2013
    Q_snprintf( _compilePath, MASTERPATH_MAXLEN, "%s/bin", _wd );
#else
    Q_snprintf( _compilePath, MASTERPATH_MAXLEN, "%s%s/%s", _wdTmp, _acc, _cmp );
#endif

#ifdef SHADER_EDITOR_DLL_2013
    char szCurrentDir[ MASTERPATH_MAXLEN ];
    Q_FileBase( _wd, szCurrentDir, MASTERPATH_MAXLEN );
    Q_snprintf( _compilePath_Local, MASTERPATH_MAXLEN, "%scommon\\%s\\bin", localize, szCurrentDir );
#else
    Q_snprintf( _compilePath_Local, MASTERPATH_MAXLEN, "%s%s\\%s", localize, _acc, _cmp );
#endif

#ifdef SHADER_EDITOR_DLL_2013
    if ( *szSearchPath != 0 )
    {
        Q_strncpy( _compilePath, szSearchPath, sizeof( _compilePath ) );
        Q_strncpy( _compilePath_Local, szSearchPath, sizeof( _compilePath_Local ) );
    }
#endif

    Q_FixSlashes( _compilePath );
    Q_FixSlashes( _compilePath_Local );
    pKV->deleteThis();


    const char *__localrootdir = "shadereditorui";
    Q_snprintf( _seditRoot, MASTERPATH_MAXLEN, "%s/%s", _gamePath, __localrootdir );
    Q_FixSlashes( _seditRoot );

    const char *__localcanvasdir = "canvas";
    Q_snprintf( _canvasDir, MASTERPATH_MAXLEN, "%s/%s", _seditRoot, __localcanvasdir );
    Q_FixSlashes( _canvasDir );

    const char *__localsrcdir = "shader_src";
    Q_snprintf( _shaderSource, MASTERPATH_MAXLEN, "%s/%s", _seditRoot, __localsrcdir );
    Q_FixSlashes( _shaderSource );

    const char *__localdumpdir = "dumps";
    Q_snprintf( _DumpFiles, MASTERPATH_MAXLEN, "%s/%s", _seditRoot, __localdumpdir );
    Q_FixSlashes( _DumpFiles );

    const char *__localufuncdir = "user_functions";
    Q_snprintf( _uFuncs, MASTERPATH_MAXLEN, "%s/%s", _seditRoot, __localufuncdir );
    Q_FixSlashes( _uFuncs );

#ifdef SHADER_EDITOR_DLL_SWARM
    const char *__swarmShaderTarget = "platform/shaders/fxc";
    Q_snprintf( _swarmShaderDir, MASTERPATH_MAXLEN, "%s/%s", _wd, __swarmShaderTarget );
    Q_FixSlashes( _swarmShaderDir );
#endif


    ApplyDirectoryOverrides();

    CreateDirectories();


    if ( shaderEdit->ShouldShowPrimaryDbg() )
    {
        Msg( "wd: %s\n", _wd );
#ifdef SHADER_EDITOR_DLL_SWARM
        Msg( "swarm parent name: %s\n", _acc );
        Msg( "swarm shader path: %s\n", _swarmShaderDir );
#else
        Msg( "acc: %s\n", _acc );
#endif
        Msg( "game: %s\n", _gamePath );
        Msg( "editor root: %s\n", _seditRoot );
        Msg( "binaries: %s\n", _compilePath );
        Msg( "binaries local: %s\n", _compilePath_Local );
        Msg( "canvas: %s\n", _canvasDir );
        Msg( "funcs: %s\n", _uFuncs );
        Msg( "src: %s\n", _shaderSource );
    }
}
//-----------------------------------------------------------------------------
// Purpose: Loads and initializes all the modules specified in the platform file
//-----------------------------------------------------------------------------
bool CVGuiSystemModuleLoader::LoadPlatformModules(CreateInterfaceFn *factorylist, int factorycount, bool useSteamModules)
{
	if ( IsX360() )
	{
		// not valid for 360
		return false;
	}

	bool bSuccess = true;

	// load platform menu
	KeyValues *kv = new KeyValues("Platform");
	if (!kv->LoadFromFile(g_pFullFileSystem, "steam/games/PlatformMenu.vdf", "PLATFORM"))
	{
		kv->deleteThis();
		return false;
	}

	// walk the platform menu loading all the interfaces
	KeyValues *menuKeys = kv->FindKey("Menu", true);
	for (KeyValues *it = menuKeys->GetFirstSubKey(); it != NULL; it = it->GetNextKey())
	{
		// see if we should skip steam modules
		if (!useSteamModules && it->GetInt("SteamApp"))
			continue;

		const char *pchInterface = it->GetString("interface");

		// don't load friends if we are using Steam Community
		if ( !Q_stricmp( pchInterface, "VGuiModuleTracker001" ) && bSteamCommunityFriendsVersion )
			continue;

		// get copy out of steam cache
		const char *dllPath = it->GetString("dll");

		// load the module (LoadModule calls GetLocalCopy() under steam)
		CSysModule *mod = g_pFullFileSystem->LoadModule(dllPath, "EXECUTABLE_PATH");
		if (!mod)
		{
			Error("Platform Error: bad module '%s', not loading\n", it->GetString("dll"));
			bSuccess = false;
			continue;
		}

		// make sure we get the right version
		IVGuiModule *moduleInterface = (IVGuiModule *)Sys_GetFactory(mod)(pchInterface, NULL);
		if (!moduleInterface)
		{
			Warning("Platform Error: module version ('%s, %s) invalid, not loading\n", it->GetString("dll"), it->GetString("interface"));
			bSuccess = false;
			continue;
		}

		// store off the module
		int newIndex = m_Modules.AddToTail();
		m_Modules[newIndex].module = mod;
		m_Modules[newIndex].moduleInterface = moduleInterface;
		m_Modules[newIndex].data = it;
	}

	m_pPlatformModuleData = kv;
	return InitializeAllModules(factorylist, factorycount) && bSuccess;
}
void CSpectatorMenu::Update( void )
{
	IGameResources *gr = GameResources();

	Reset();

	if ( m_iDuckKey == BUTTON_CODE_INVALID )
	{
		m_iDuckKey = gameuifuncs->GetButtonCodeForBind( "duck" );
	}

	if ( !gr )
		return;

	int iPlayerIndex;
	for ( iPlayerIndex = 1 ; iPlayerIndex <= gpGlobals->maxClients; iPlayerIndex++ )
	{

		// does this slot in the array have a name?
		if ( !gr->IsConnected( iPlayerIndex ) )
			continue;

		if ( gr->IsLocalPlayer( iPlayerIndex ) )
			continue;

		if ( !gr->IsAlive( iPlayerIndex ) )
			continue;

		wchar_t playerText[ 80 ], playerName[ 64 ], *team, teamText[ 64 ];
		char localizeTeamName[64];
		char szPlayerIndex[16];
		g_pVGuiLocalize->ConvertANSIToUnicode( UTIL_SafeName( gr->GetPlayerName(iPlayerIndex) ), playerName, sizeof( playerName ) );
		const char * teamname = gr->GetTeamName( gr->GetTeam(iPlayerIndex) );
		if ( teamname )
		{	
			Q_snprintf( localizeTeamName, sizeof( localizeTeamName ), "#%s", teamname );
			team=g_pVGuiLocalize->Find( localizeTeamName );

			if ( !team ) 
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( teamname , teamText, sizeof( teamText ) );
				team = teamText;
			}

			g_pVGuiLocalize->ConstructString( playerText, sizeof( playerText ), g_pVGuiLocalize->Find( "#Spec_PlayerItem_Team" ), 2, playerName, team );
		}
		else
		{
			g_pVGuiLocalize->ConstructString( playerText, sizeof( playerText ), g_pVGuiLocalize->Find( "#Spec_PlayerItem" ), 1, playerName );
		}

		Q_snprintf( szPlayerIndex, sizeof( szPlayerIndex ), "%d", iPlayerIndex );

		KeyValues *kv = new KeyValues( "UserData", "player", gr->GetPlayerName( iPlayerIndex ), "index", szPlayerIndex );
		m_pPlayerList->AddItem( playerText, kv );
		kv->deleteThis();
	}

	// make sure the player combo box is up to date
	int playernum = GetSpectatorTarget();
	const char *selectedPlayerName = gr->GetPlayerName( playernum );
	for ( iPlayerIndex=0; iPlayerIndex<m_pPlayerList->GetItemCount(); ++iPlayerIndex )
	{
		KeyValues *kv = m_pPlayerList->GetItemUserData( iPlayerIndex );
		if ( kv && FStrEq( kv->GetString( "player" ), selectedPlayerName ) )
		{
			m_pPlayerList->ActivateItemByRow( iPlayerIndex );
			break;
		}
	}

	//=============================================================================
	// HPE_BEGIN:
	// [pfreese] make sure the view mode combo box is up to date - the spectator 
	// mode can be changed multiple ways
	//=============================================================================
	
	int specmode = GetSpectatorMode();
	m_pViewOptions->SetText(s_SpectatorModes[specmode]);
	
	//=============================================================================
	// HPE_END
	//=============================================================================
}
void CTFOptionsVideoPanel::CreateControls()
{
	BaseClass::CreateControls();

	m_bRequireRestart = false;

	CTFAdvButton *pTitleVideo = new CTFAdvButton(this, "DescTextTitle", "Video");
	m_pMode = new ComboBox(this, "Resolution", 8, false);
	m_pAspectRatio = new ComboBox(this, "AspectRatio", 6, false);

	char pszAspectName[3][64];
	wchar_t *unicodeText = g_pVGuiLocalize->Find("#GameUI_AspectNormal");
	g_pVGuiLocalize->ConvertUnicodeToANSI(unicodeText, pszAspectName[0], 32);
	unicodeText = g_pVGuiLocalize->Find("#GameUI_AspectWide16x9");
	g_pVGuiLocalize->ConvertUnicodeToANSI(unicodeText, pszAspectName[1], 32);
	unicodeText = g_pVGuiLocalize->Find("#GameUI_AspectWide16x10");
	g_pVGuiLocalize->ConvertUnicodeToANSI(unicodeText, pszAspectName[2], 32);

	int iNormalItemID = m_pAspectRatio->AddItem(pszAspectName[0], NULL);
	int i16x9ItemID = m_pAspectRatio->AddItem(pszAspectName[1], NULL);
	int i16x10ItemID = m_pAspectRatio->AddItem(pszAspectName[2], NULL);

	const MaterialSystem_Config_t &config = materials->GetCurrentConfigForVideoCard();

	int iAspectMode = GetScreenAspectMode(config.m_VideoMode.m_Width, config.m_VideoMode.m_Height);
	switch (iAspectMode)
	{
	default:
	case 0:
		m_pAspectRatio->ActivateItem(iNormalItemID);
		break;
	case 1:
		m_pAspectRatio->ActivateItem(i16x9ItemID);
		break;
	case 2:
		m_pAspectRatio->ActivateItem(i16x10ItemID);
		break;
	}

	m_pWindowed = new ComboBox(this, "DisplayModeCombo", 6, false);
	m_pWindowed->AddItem("#GameUI_Fullscreen", NULL);
	m_pWindowed->AddItem("#GameUI_Windowed", NULL);

	m_pGammaSlider = new CCvarSlider(this, "Gamma", "#GameUI_Gamma", 1.6f, 2.6f, "mat_monitorgamma");

	// Moved down here so we can set the Drop down's 
	// menu state after the default (disabled) value is loaded
	PrepareResolutionList();

	// only show the benchmark button if they have the benchmark map
	//if (!g_pFullFileSystem->FileExists("maps/test_hardware.bsp"))
	//{
	//	m_pBenchmark->SetVisible(false);
	//}
	AddControl(pTitleVideo, O_CATEGORY);
	AddControl(m_pMode, O_LIST, "#GameUI_Resolution");
	AddControl(m_pAspectRatio, O_LIST, "#GameUI_AspectRatio");
	AddControl(m_pWindowed, O_LIST, "#GameUI_DisplayMode");
	AddControl(m_pGammaSlider, O_SLIDER);


	//VIDEOADV
	CTFAdvButton *pTitleVideoAdv = new CTFAdvButton(this, "DescTextTitle", "#GameUI_VideoAdvanced_Title");

	m_pDXLevel = new ComboBox(this, "dxlabel", 6, false);
	KeyValues *pKeyValues = new KeyValues("config");
	materials->GetRecommendedConfigurationInfo(0, pKeyValues);
	m_pDXLevel->DeleteAllItems();
	for (int i = 0; i < ARRAYSIZE(g_DirectXLevels); i++)
	{
		// don't allow choice of lower dxlevels than the default, 
		// unless we're already at that lower level or have it forced
		if (!CommandLine()->CheckParm("-dxlevel") &&
			g_DirectXLevels[i] != config.dxSupportLevel &&
			g_DirectXLevels[i] < pKeyValues->GetInt("ConVar.mat_dxlevel"))
			continue;

		KeyValues *pTempKV = new KeyValues("config");
		if (g_DirectXLevels[i] == pKeyValues->GetInt("ConVar.mat_dxlevel")
			|| materials->GetRecommendedConfigurationInfo(g_DirectXLevels[i], pTempKV))
		{
			// add the configuration in the combo
			char szDXLevelName[64];
			GetNameForDXLevel(g_DirectXLevels[i], szDXLevelName, sizeof(szDXLevelName));
			m_pDXLevel->AddItem(szDXLevelName, new KeyValues("dxlevel", "dxlevel", g_DirectXLevels[i]));
		}

		pTempKV->deleteThis();
	}
	pKeyValues->deleteThis();

	m_pModelDetail = new ComboBox(this, "ModelDetail", 6, false);
	m_pModelDetail->AddItem("#gameui_low", NULL);
	m_pModelDetail->AddItem("#gameui_medium", NULL);
	m_pModelDetail->AddItem("#gameui_high", NULL);

	m_pTextureDetail = new ComboBox(this, "TextureDetail", 6, false);
	m_pTextureDetail->AddItem("#gameui_low", NULL);
	m_pTextureDetail->AddItem("#gameui_medium", NULL);
	m_pTextureDetail->AddItem("#gameui_high", NULL);
	m_pTextureDetail->AddItem("#gameui_ultra", NULL);

	// Build list of MSAA and CSAA modes, based upon those which are supported by the device
	//
	// The modes that we've seen in the wild to date are as follows (in perf order, fastest to slowest)
	//
	//								2x	4x	6x	8x	16x	8x	16xQ
	//		Texture/Shader Samples	1	1	1	1	1	1	1
	//		Stored Color/Z Samples	2	4	6	4	4	8	8
	//		Coverage Samples		2	4	6	8	16	8	16
	//		MSAA or CSAA			M	M	M	C	C	M	C
	//
	//	The CSAA modes are nVidia only (added in the G80 generation of GPUs)
	//
	m_nNumAAModes = 0;
	m_pAntialiasingMode = new ComboBox(this, "AntialiasingMode", 10, false);
	m_pAntialiasingMode->AddItem("#GameUI_None", NULL);
	m_nAAModes[m_nNumAAModes].m_nNumSamples = 1;
	m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
	m_nNumAAModes++;

	if (materials->SupportsMSAAMode(2))
	{
		m_pAntialiasingMode->AddItem("#GameUI_2X", NULL);
		m_nAAModes[m_nNumAAModes].m_nNumSamples = 2;
		m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
		m_nNumAAModes++;
	}

	if (materials->SupportsMSAAMode(4))
	{
		m_pAntialiasingMode->AddItem("#GameUI_4X", NULL);
		m_nAAModes[m_nNumAAModes].m_nNumSamples = 4;
		m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
		m_nNumAAModes++;
	}

	if (materials->SupportsMSAAMode(6))
	{
		m_pAntialiasingMode->AddItem("#GameUI_6X", NULL);
		m_nAAModes[m_nNumAAModes].m_nNumSamples = 6;
		m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
		m_nNumAAModes++;
	}

	if (materials->SupportsCSAAMode(4, 2))							// nVidia CSAA			"8x"
	{
		m_pAntialiasingMode->AddItem("#GameUI_8X_CSAA", NULL);
		m_nAAModes[m_nNumAAModes].m_nNumSamples = 4;
		m_nAAModes[m_nNumAAModes].m_nQualityLevel = 2;
		m_nNumAAModes++;
	}

	if (materials->SupportsCSAAMode(4, 4))							// nVidia CSAA			"16x"
	{
		m_pAntialiasingMode->AddItem("#GameUI_16X_CSAA", NULL);
		m_nAAModes[m_nNumAAModes].m_nNumSamples = 4;
		m_nAAModes[m_nNumAAModes].m_nQualityLevel = 4;
		m_nNumAAModes++;
	}

	if (materials->SupportsMSAAMode(8))
	{
		m_pAntialiasingMode->AddItem("#GameUI_8X", NULL);
		m_nAAModes[m_nNumAAModes].m_nNumSamples = 8;
		m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
		m_nNumAAModes++;
	}

	if (materials->SupportsCSAAMode(8, 2))							// nVidia CSAA			"16xQ"
	{
		m_pAntialiasingMode->AddItem("#GameUI_16XQ_CSAA", NULL);
		m_nAAModes[m_nNumAAModes].m_nNumSamples = 8;
		m_nAAModes[m_nNumAAModes].m_nQualityLevel = 2;
		m_nNumAAModes++;
	}

	m_pFilteringMode = new ComboBox(this, "FilteringMode", 6, false);
	m_pFilteringMode->AddItem("#GameUI_Bilinear", NULL);
	m_pFilteringMode->AddItem("#GameUI_Trilinear", NULL);
	m_pFilteringMode->AddItem("#GameUI_Anisotropic2X", NULL);
	m_pFilteringMode->AddItem("#GameUI_Anisotropic4X", NULL);
	m_pFilteringMode->AddItem("#GameUI_Anisotropic8X", NULL);
	m_pFilteringMode->AddItem("#GameUI_Anisotropic16X", NULL);

	m_pShadowDetail = new ComboBox(this, "ShadowDetail", 6, false);
	m_pShadowDetail->AddItem("#gameui_low", NULL);
	m_pShadowDetail->AddItem("#gameui_medium", NULL);
	if (materials->SupportsShadowDepthTextures())
	{
		m_pShadowDetail->AddItem("#gameui_high", NULL);
	}

	ConVarRef mat_dxlevel("mat_dxlevel");

	m_pHDR = new ComboBox(this, "HDR", 6, false);
	m_pHDR->AddItem("#GameUI_hdr_level0", NULL);
	m_pHDR->AddItem("#GameUI_hdr_level1", NULL);

	if (materials->SupportsHDRMode(HDR_TYPE_INTEGER))
	{
		m_pHDR->AddItem("#GameUI_hdr_level2", NULL);
	}
#if 0
	if (materials->SupportsHDRMode(HDR_TYPE_FLOAT))
	{
		m_pHDR->AddItem("#GameUI_hdr_level3", NULL);
	}
#endif

	m_pHDR->SetEnabled(mat_dxlevel.GetInt() >= 80);

	m_pWaterDetail = new ComboBox(this, "WaterDetail", 6, false);
	m_pWaterDetail->AddItem("#gameui_noreflections", NULL);
	m_pWaterDetail->AddItem("#gameui_reflectonlyworld", NULL);
	m_pWaterDetail->AddItem("#gameui_reflectall", NULL);

	m_pVSync = new ComboBox(this, "VSync", 2, false);
	m_pVSync->AddItem("#gameui_disabled", NULL);
	m_pVSync->AddItem("#gameui_enabled", NULL);

	m_pShaderDetail = new ComboBox(this, "ShaderDetail", 6, false);
	m_pShaderDetail->AddItem("#gameui_low", NULL);
	m_pShaderDetail->AddItem("#gameui_high", NULL);

	m_pColorCorrection = new ComboBox(this, "ColorCorrection", 2, false);
	m_pColorCorrection->AddItem("#gameui_disabled", NULL);
	m_pColorCorrection->AddItem("#gameui_enabled", NULL);

	m_pMotionBlur = new ComboBox(this, "MotionBlur", 2, false);
	m_pMotionBlur->AddItem("#gameui_disabled", NULL);
	m_pMotionBlur->AddItem("#gameui_enabled", NULL);

	m_pQueuedMode = new ComboBox(this, "Multicore", 2, false);
	m_pQueuedMode->AddItem("#gameui_disabled", NULL);
	m_pQueuedMode->AddItem("#gameui_enabled", NULL);

	m_pFOVSlider = new CCvarSlider(NULL, "FOV", "#GameUI_FOV", 75.0f, 100.0f, "fov_desired");

	m_pDXLevel->SetVisible(false);

	m_pColorCorrection->SetEnabled(mat_dxlevel.GetInt() >= 90);
	m_pMotionBlur->SetEnabled(mat_dxlevel.GetInt() >= 90);

	//MarkDefaultSettingsAsRecommended();
	m_bUseChanges = false;

	AddControl(pTitleVideoAdv, O_CATEGORY);
	AddControl(m_pModelDetail, O_LIST, "#GameUI_Model_Detail");
	AddControl(m_pTextureDetail, O_LIST, "#GameUI_Texture_Detail");
	AddControl(m_pShadowDetail, O_LIST, "#GameUI_Shadow_Detail");
	AddControl(m_pWaterDetail, O_LIST, "#GameUI_Water_Detail");
	AddControl(m_pShaderDetail, O_LIST, "#GameUI_Shader_Detail");
	AddControl(m_pColorCorrection, O_LIST, "#GameUI_Color_Correction");
	AddControl(m_pAntialiasingMode, O_LIST, "#GameUI_Antialiasing_Mode");
	AddControl(m_pFilteringMode, O_LIST, "#GameUI_Filtering_Mode");
	AddControl(m_pVSync, O_LIST, "#GameUI_Wait_For_VSync");
	AddControl(m_pMotionBlur, O_LIST, "#GameUI_MotionBlur");
	AddControl(m_pFOVSlider, O_SLIDER);
	AddControl(m_pQueuedMode, O_LIST, "#GameUI_MulticoreRendering");
	AddControl(m_pHDR, O_LIST, "#GameUI_HDR");
}
Example #23
0
void CHudAnimationInfo::PaintMappingInfo( int& x, int& y, Panel *element, PanelAnimationMap *map )
{
	if ( !map )
		return;

	// Draw label
	surface()->DrawSetTextFont( m_LabelFont );
	surface()->DrawSetTextColor( m_LabelColor );
	surface()->DrawSetTextPos( x, y );

	const char *className = "";
	if ( map->pfnClassName )
	{
		className = (*map->pfnClassName)();
	}

	const char *p = className;
	while ( *p )
	{
		surface()->DrawUnicodeChar( *p );
		p++;
	}

	y += surface()->GetFontTall( m_LabelFont ) + 1;

	x += 10;


	int c = map->entries.Count();
	for ( int i = 0; i < c; i++ )
	{
		PanelAnimationMapEntry *e = &map->entries[ i ];

		char sz[ 512 ];
		char value[ 256 ];

		Color col( 0, 0, 0, 0 );
		Color  *pColor = NULL;
		KeyValues *kv = new KeyValues( e->name() );
		if ( element->RequestInfo( kv ) )
		{
			KeyValues *dat = kv->FindKey(e->name());
			if ( dat && dat->GetDataType() == KeyValues::TYPE_COLOR )
			{
				col = dat->GetColor();
				Q_snprintf( value, sizeof( value ), "%i, %i, %i, %i",
					col[0], col[1], col[2], col[3] );
				pColor = &col;
			}
			else
			{
				Q_snprintf( value, sizeof( value ), "%s",
					dat->GetString() );
			}
		}
		else
		{
			Q_strncpy( value, "???", sizeof( value ) );
		}

		Q_snprintf( sz, sizeof( sz ), "%-30s %-20s (%s)",
			e->name(), e->type(), value );

		kv->deleteThis();

		PaintString( x, y, sz, pColor );
	}

	x -= 10;

	if ( map->baseMap )
	{
		PaintMappingInfo( x, y, element, map->baseMap );
	}
}
void CTFOptionsVideoPanel::MarkDefaultSettingsAsRecommended()
{
	// Pull in data from dxsupport.cfg database (includes fine-grained per-vendor/per-device config data)
	KeyValues *pKeyValues = new KeyValues("config");
	materials->GetRecommendedConfigurationInfo(0, pKeyValues);

	// Read individual values from keyvalues which came from dxsupport.cfg database
	int nSkipLevels = pKeyValues->GetInt("ConVar.mat_picmip", 0);
	int nAnisotropicLevel = pKeyValues->GetInt("ConVar.mat_forceaniso", 1);
	int nForceTrilinear = pKeyValues->GetInt("ConVar.mat_trilinear", 0);
	int nAASamples = pKeyValues->GetInt("ConVar.mat_antialias", 0);
	int nAAQuality = pKeyValues->GetInt("ConVar.mat_aaquality", 0);
	int nRenderToTextureShadows = pKeyValues->GetInt("ConVar.r_shadowrendertotexture", 0);
	int nShadowDepthTextureShadows = pKeyValues->GetInt("ConVar.r_flashlightdepthtexture", 0);
#ifndef _X360
	int nWaterUseRealtimeReflection = pKeyValues->GetInt("ConVar.r_waterforceexpensive", 0);
#endif
	int nWaterUseEntityReflection = pKeyValues->GetInt("ConVar.r_waterforcereflectentities", 0);
	int nMatVSync = pKeyValues->GetInt("ConVar.mat_vsync", 1);
	int nRootLOD = pKeyValues->GetInt("ConVar.r_rootlod", 0);
	int nReduceFillRate = pKeyValues->GetInt("ConVar.mat_reducefillrate", 0);
	int nDXLevel = pKeyValues->GetInt("ConVar.mat_dxlevel", 0);
	int nColorCorrection = pKeyValues->GetInt("ConVar.mat_colorcorrection", 0);
	int nMotionBlur = pKeyValues->GetInt("ConVar.mat_motion_blur_enabled", 0);

	int nQueuedMode;
	if (GetCPUInformation()->m_nPhysicalProcessors >= 2)
	{
		nQueuedMode = -1;
	}
	else
	{
		nQueuedMode = 0;
	}

	// Only recommend a dxlevel if there is more than one available
	if (m_pDXLevel->GetItemCount() > 1)
	{
		for (int i = 0; i < m_pDXLevel->GetItemCount(); i++)
		{
			KeyValues *kv = m_pDXLevel->GetItemUserData(i);
			if (kv->GetInt("dxlevel") == pKeyValues->GetInt("ConVar.mat_dxlevel"))
			{
				SetComboItemAsRecommended(m_pDXLevel, i);
				break;
			}
		}
	}

	SetComboItemAsRecommended(m_pModelDetail, 2 - nRootLOD);
	SetComboItemAsRecommended(m_pTextureDetail, 2 - nSkipLevels);

	switch (nAnisotropicLevel)
	{
	case 2:
		SetComboItemAsRecommended(m_pFilteringMode, 2);
		break;
	case 4:
		SetComboItemAsRecommended(m_pFilteringMode, 3);
		break;
	case 8:
		SetComboItemAsRecommended(m_pFilteringMode, 4);
		break;
	case 16:
		SetComboItemAsRecommended(m_pFilteringMode, 5);
		break;
	case 0:
	default:
		if (nForceTrilinear != 0)
		{
			SetComboItemAsRecommended(m_pFilteringMode, 1);
		}
		else
		{
			SetComboItemAsRecommended(m_pFilteringMode, 0);
		}
		break;
	}

	// Map desired mode to list item number
	int nMSAAMode = FindMSAAMode(nAASamples, nAAQuality);
	SetComboItemAsRecommended(m_pAntialiasingMode, nMSAAMode);

	if (nShadowDepthTextureShadows)
		SetComboItemAsRecommended(m_pShadowDetail, 2);	// Shadow depth mapping (in addition to RTT shadows)
	else if (nRenderToTextureShadows)
		SetComboItemAsRecommended(m_pShadowDetail, 1);	// RTT shadows
	else
		SetComboItemAsRecommended(m_pShadowDetail, 0);	// Blobbies

	SetComboItemAsRecommended(m_pShaderDetail, nReduceFillRate ? 0 : 1);

#ifndef _X360
	if (nWaterUseRealtimeReflection)
#endif
	{
		if (nWaterUseEntityReflection)
		{
			SetComboItemAsRecommended(m_pWaterDetail, 2);
		}
		else
		{
			SetComboItemAsRecommended(m_pWaterDetail, 1);
		}
	}
#ifndef _X360
	else
	{
		SetComboItemAsRecommended(m_pWaterDetail, 0);
	}
#endif

	SetComboItemAsRecommended(m_pVSync, nMatVSync != 0);

	SetComboItemAsRecommended(m_pHDR, nDXLevel >= 90 ? 2 : 0);

	SetComboItemAsRecommended(m_pColorCorrection, nColorCorrection);

	SetComboItemAsRecommended(m_pMotionBlur, nMotionBlur);

	SetComboItemAsRecommended(m_pQueuedMode, nQueuedMode);

	pKeyValues->deleteThis();
}
Example #25
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : scale - 
//			attachmentIndex - 
//			bOneFrame - 
//-----------------------------------------------------------------------------
void FX_MuzzleEffectAttached( 
	float scale, 
	ClientEntityHandle_t hEntity, 
	int attachmentIndex, 
	unsigned char *pFlashColor,
	bool bOneFrame )
{
	VPROF_BUDGET( "FX_MuzzleEffect", VPROF_BUDGETGROUP_PARTICLE_RENDERING );

	// If the material isn't available, let's not do anything.
	if ( g_Mat_SMG_Muzzleflash[0] == NULL )
	{
		return;
	}
	
	CSmartPtr<CLocalSpaceEmitter> pSimple = CLocalSpaceEmitter::Create( "MuzzleFlash", hEntity, attachmentIndex );
	Assert( pSimple );
	if ( pSimple == NULL )
		return;
	
	// Lock our bounding box
	pSimple->GetBinding().SetBBox( -( Vector( 16, 16, 16 ) * scale ), ( Vector( 16, 16, 16 ) * scale ) );
	
	SimpleParticle *pParticle;
	Vector			forward(1,0,0), offset;

	float flScale = random->RandomFloat( scale-0.25f, scale+0.25f );

	if ( flScale < 0.5f )
	{
		flScale = 0.5f;
	}
	else if ( flScale > 8.0f )
	{
		flScale = 8.0f;
	}

	//
	// Flash
	//

	int i;
	for ( i = 1; i < 9; i++ )
	{
		offset = (forward * (i*2.0f*scale));

		pParticle = (SimpleParticle *) pSimple->AddParticle( sizeof( SimpleParticle ), g_Mat_SMG_Muzzleflash[random->RandomInt(0,3)], offset );
			
		if ( pParticle == NULL )
			return;

		pParticle->m_flLifetime		= 0.0f;
		pParticle->m_flDieTime		= bOneFrame ? 0.0001f : 0.1f;

		pParticle->m_vecVelocity.Init();

		if ( !pFlashColor )
		{
			pParticle->m_uchColor[0]	= 255;
			pParticle->m_uchColor[1]	= 255;
			pParticle->m_uchColor[2]	= 255;
		}
		else
		{
			pParticle->m_uchColor[0]	= pFlashColor[0];
			pParticle->m_uchColor[1]	= pFlashColor[1];
			pParticle->m_uchColor[2]	= pFlashColor[2];
		}

		pParticle->m_uchStartAlpha	= 255;
		pParticle->m_uchEndAlpha	= 128;

		pParticle->m_uchStartSize	= (random->RandomFloat( 6.0f, 9.0f ) * (12-(i))/9) * flScale;
		pParticle->m_uchEndSize		= pParticle->m_uchStartSize;
		pParticle->m_flRoll			= random->RandomInt( 0, 360 );
		pParticle->m_flRollDelta	= 0.0f;
	}


	if ( !ToolsEnabled() )
		return;

	if ( !clienttools->IsInRecordingMode() )
		return;

	C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle( hEntity );
	if ( pEnt )
	{
		pEnt->RecordToolMessage();
	}

	// NOTE: Particle system destruction message will be sent by the particle effect itself.
	int nId = pSimple->AllocateToolParticleEffectId();

	KeyValues *msg = new KeyValues( "OldParticleSystem_Create" );
	msg->SetString( "name", "FX_MuzzleEffectAttached" );
	msg->SetInt( "id", nId );
	msg->SetFloat( "time", gpGlobals->curtime );

	KeyValues *pEmitter = msg->FindKey( "DmeSpriteEmitter", true );
	pEmitter->SetInt( "count", 9 );
	pEmitter->SetFloat( "duration", 0 );
	pEmitter->SetString( "material", "effects/muzzleflash2" ); // FIXME - create DmeMultiMaterialSpriteEmitter to support the 4 materials of muzzleflash
	pEmitter->SetInt( "active", true );

	KeyValues *pInitializers = pEmitter->FindKey( "initializers", true );

	KeyValues *pPosition = pInitializers->FindKey( "DmeLinearAttachedPositionInitializer", true );
	pPosition->SetPtr( "entindex", (void*)pEnt->entindex() );
	pPosition->SetInt( "attachmentIndex", attachmentIndex );
	pPosition->SetFloat( "linearOffsetX", 2.0f * scale );

	// TODO - create a DmeConstantLifetimeInitializer
	KeyValues *pLifetime = pInitializers->FindKey( "DmeRandomLifetimeInitializer", true );
	pLifetime->SetFloat( "minLifetime", bOneFrame ? 1.0f / 24.0f : 0.1f );
	pLifetime->SetFloat( "maxLifetime", bOneFrame ? 1.0f / 24.0f : 0.1f );

	KeyValues *pVelocity = pInitializers->FindKey( "DmeConstantVelocityInitializer", true );
	pVelocity->SetFloat( "velocityX", 0.0f );
	pVelocity->SetFloat( "velocityY", 0.0f );
	pVelocity->SetFloat( "velocityZ", 0.0f );

	KeyValues *pRoll = pInitializers->FindKey( "DmeRandomRollInitializer", true );
	pRoll->SetFloat( "minRoll", 0.0f );
	pRoll->SetFloat( "maxRoll", 360.0f );

	// TODO - create a DmeConstantRollSpeedInitializer
	KeyValues *pRollSpeed = pInitializers->FindKey( "DmeRandomRollSpeedInitializer", true );
	pRollSpeed->SetFloat( "minRollSpeed", 0.0f );
	pRollSpeed->SetFloat( "maxRollSpeed", 0.0f );

	// TODO - create a DmeConstantColorInitializer
	KeyValues *pColor = pInitializers->FindKey( "DmeRandomInterpolatedColorInitializer", true );
	Color color( pFlashColor ? pFlashColor[ 0 ] : 255, pFlashColor ? pFlashColor[ 1 ] : 255, pFlashColor ? pFlashColor[ 2 ] : 255, 255 );
	pColor->SetColor( "color1", color );
	pColor->SetColor( "color2", color );

	// TODO - create a DmeConstantAlphaInitializer
	KeyValues *pAlpha = pInitializers->FindKey( "DmeRandomAlphaInitializer", true );
	pAlpha->SetInt( "minStartAlpha", 255 );
	pAlpha->SetInt( "maxStartAlpha", 255 );
	pAlpha->SetInt( "minEndAlpha", 128 );
	pAlpha->SetInt( "maxEndAlpha", 128 );

	// size = rand(6..9) * indexed(12/9..4/9) * flScale = rand(6..9) * ( 4f + f * i )
	KeyValues *pSize = pInitializers->FindKey( "DmeMuzzleFlashSizeInitializer", true );
	float f = flScale / 9.0f;
	pSize->SetFloat( "indexedBase", 4.0f * f );
	pSize->SetFloat( "indexedDelta", f );
	pSize->SetFloat( "minRandomFactor", 6.0f );
	pSize->SetFloat( "maxRandomFactor", 9.0f );

/*
	KeyValues *pUpdaters = pEmitter->FindKey( "updaters", true );

	pUpdaters->FindKey( "DmePositionVelocityUpdater", true );
	pUpdaters->FindKey( "DmeRollUpdater", true );
	pUpdaters->FindKey( "DmeAlphaLinearUpdater", true );
	pUpdaters->FindKey( "DmeSizeUpdater", true );
*/
	ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
	msg->deleteThis();
}
void CASW_Mission_Chooser_Source_Local::AddToSavedCampaignList(const char *szSaveName)
{
	// find out what campaign this save is for
	char szFullFileName[256];
	Q_snprintf(szFullFileName, sizeof(szFullFileName), "save/%s", szSaveName);
	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, szFullFileName))
	{
		const char *pCampaignName = pSaveKeyValues->GetString("CampaignName");
		// check the campaign exists
		char tempfile[MAX_PATH];
		Q_snprintf( tempfile, sizeof( tempfile ), "resource/campaigns/%s.txt", pCampaignName );
		if (g_pFullFileSystem->FileExists(tempfile))
		{
			ASW_Mission_Chooser_Saved_Campaign item;
			Q_snprintf(item.m_szSaveName, sizeof(item.m_szSaveName), "%s", szSaveName);
			Q_snprintf(item.m_szCampaignName, sizeof(item.m_szCampaignName), "%s", pCampaignName);
			Q_snprintf(item.m_szDateTime, sizeof(item.m_szDateTime), "%s", pSaveKeyValues->GetString("DateTime"));
			//Msg("save %s multiplayer %d\n", szSaveName, pSaveKeyValues->GetInt("Multiplayer"));
			item.m_bMultiplayer = (pSaveKeyValues->GetInt("Multiplayer") > 0);
			//Msg("item multiplayer = %d\n", item.m_bMultiplayer);

			// check subsections for player names and player IDs, concat them into two strings
			char namebuffer[256];
			char idbuffer[512];
			namebuffer[0] = '\0';
			idbuffer[0] = '\0';
			int namepos = 0;
			int idpos = 0;
			KeyValues *pkvSubSection = pSaveKeyValues->GetFirstSubKey();
			while ( pkvSubSection )
			{
				if ((Q_stricmp(pkvSubSection->GetName(), "PLAYER")==0) && namepos < 253)
				{
					const char *pName = pkvSubSection->GetString("PlayerName");
					if (pName && pName[0] != '\0')
					{
						int namelength = Q_strlen(pName);
						for (int charcopy=0; charcopy<namelength && namepos<253; charcopy++)
						{
							namebuffer[namepos] = pName[charcopy];
							namepos++;
						}
						namebuffer[namepos] = ' '; namepos++;
						namebuffer[namepos] = '\0';
					}
				}
				if ((Q_stricmp(pkvSubSection->GetName(), "DATA")==0) && idpos < 253)
				{
					const char *pID = pkvSubSection->GetString("DataBlock");
					if (pID && pID[0] != '\0')
					{
						int idlength = Q_strlen(pID);
						for (int charcopy=0; charcopy<idlength && idpos<253; charcopy++)
						{
							idbuffer[idpos] = pID[charcopy];
							idpos++;
						}
						idbuffer[idpos] = ' '; idpos++;
						idbuffer[idpos] = '\0';
					}
				}
				pkvSubSection = pkvSubSection->GetNextKey();
			}
			Q_snprintf(item.m_szPlayerNames, sizeof(item.m_szPlayerNames), "%s", namebuffer);
			Q_snprintf(item.m_szPlayerIDs, sizeof(item.m_szPlayerIDs), "%s", idbuffer);
			item.m_iMissionsComplete = pSaveKeyValues->GetInt("NumMissionsComplete");
			m_SavedCampaignList.Insert( item );
		}
	}
	pSaveKeyValues->deleteThis();

	//// check if there's now too many save games
	//int iNumMultiplayer = GetNumSavedCampaigns(true, NULL);
	//if (iNumMultiplayer > asw_max_saves.GetInt())
	//{
	//	// find the oldest one
	//	ASW_Mission_Chooser_Saved_Campaign* pChosen = false;
	//	int iChosen = -1;
	//	for (int i=m_SavedCampaignList.Count()-1; i>=0; i--)
	//	{
	//		if (m_SavedCampaignList[i].m_bMultiplayer)
	//		{
	//			pChosen = &m_SavedCampaignList[i];
	//			iChosen = i;
	//			break;
	//		}			
	//	}
	//	// delete if found
	//	if (iChosen != -1 && pChosen)
	//	{
	//		char buffer[MAX_PATH];
	//		Q_snprintf(buffer, sizeof(buffer), "save/%s", pChosen->m_szSaveName);
	//		Msg("Deleting save %s as we have too many\n", buffer);
	//		g_pFullFileSystem->RemoveFile( buffer, "GAME" );
	//		m_SavedCampaignList.Remove(iChosen);
	//	}
	//}
}
//-----------------------------------------------------------------------------
// Purpose: loads the list of available maps into the map list
//-----------------------------------------------------------------------------
void CNewGameDialog::LoadMaps()
{
	KeyValues *tmp = new KeyValues("Chapters");
	if (tmp->LoadFromFile(g_pFullFileSystem, "chapters.txt", "MOD")){

		KeyValues *work = tmp->GetFirstSubKey();
		while (work)
		{
			char mapname[256];
#if 0
			char mapname2[256];
#endif
			char aliasname[256];

			Q_strcpy(mapname, work->GetName());

			if (!Q_strcmp(mapname, "!separator")){
				maps->AddSeparator();
				goto nextFile;
			}
			else if (!Q_strcmp(mapname, "!title")){
				char title[256];
				Q_strcpy(title, work->GetString());
				char *w = (char*)g_pVGuiLocalize->FindAsUTF8(title);
				if (!w)
					Q_strcpy(w, title);
				
				maps->AddTitle(w);
				goto nextFile;
			}
				Q_strcpy(aliasname, work->GetString());
#if 0
				Q_snprintf(mapname2, sizeof(mapname2), "maps/%s.bsp", mapname);
				if (!g_pFullFileSystem->FileExists(mapname2))
				{
					goto nextFile;
				}
#endif
				char map[128];

				Q_snprintf(map, sizeof(map), "maps/%s", mapname);	//TODO: Change me!

				char localize[128];
				Q_strcpy(localize, g_pVGuiLocalize->FindAsUTF8(aliasname));

				// add to the map list
				maps->AddMap(map, mapname, (localize ? localize : aliasname));
				//maps->AddItem(mapname, new KeyValues("data", "mapname", mapname));
			
			// get the next file
		nextFile:
			work = work->GetNextKey();
		}
	}
	else{
		MessageBox *mes = new MessageBox(L"Error - Missing file", L"file 'chapters.txt' is missing from mod root folder!");
		mes->Activate(); mes->MakePopup();
	}
	tmp->deleteThis();
	//maps->CalcBestWidth();
	maps->SetPanelSize(152, 86);
}
void BuildWhiteList()
{
	// Search for unusedcontent.cfg file
	if ( !g_pFileSystem->FileExists( WHITELIST_FILE ) )
	{
		vprint( 1, "Running with no whitelist.cfg file!!!\n" );
		return;
	}

	vprint( 1, "\nBuilding whitelist\n" );

	KeyValues *kv = new KeyValues( WHITELIST_FILE );
	if ( kv )
	{
		if ( kv->LoadFromFile( g_pFileSystem, WHITELIST_FILE, NULL ) )
		{
			for ( KeyValues *sub = kv->GetFirstSubKey(); sub; sub = sub->GetNextKey() )
			{
				if ( !Q_stricmp( sub->GetName(), "add" ) )
				{
					AddToWhiteList( sub->GetString() );
				}
				else if ( !Q_stricmp( sub->GetName(), "remove" ) )
				{
					RemoveFromWhiteList( sub->GetString() );
				}
				else
				{
					vprint( 1, "Unknown subkey '%s' in %s\n", sub->GetName(), WHITELIST_FILE );
				}
			}
		}

		kv->deleteThis();
	}

	if ( verbose || printwhitelist )
	{
		vprint( 1, "Whitelist:\n\n" );


		for ( int i = g_WhiteList.FirstInorder(); 
			i != g_WhiteList.InvalidIndex(); 
			i = g_WhiteList.NextInorder( i ) )
		{
			UnusedContent::CUtlSymbol& sym = g_WhiteList[ i ];

			char const *resolved = g_Analysis.symbols.String( sym );
			vprint( 2, "  %s\n", resolved );
		}
	}

	// dump the whitelist file list anyway
	{
		filesystem->RemoveFile( "whitelist_files.txt", "GAME" );
		for ( int i = g_WhiteList.FirstInorder(); 
			i != g_WhiteList.InvalidIndex(); 
			i = g_WhiteList.NextInorder( i ) )
		{
			UnusedContent::CUtlSymbol& sym = g_WhiteList[ i ];
			char const *resolved = g_Analysis.symbols.String( sym );
			logprint( "whitelist_files.txt", "\"%s\"\n", resolved );
		}
	}


	vprint( 1, "Whitelist resolves to %d files (added %i/removed %i)\n\n", g_WhiteList.Count(), wl_added, wl_removed );
}
Example #29
0
//-----------------------------------------------------------------------------
// Purpose: loads the control settings from file
//-----------------------------------------------------------------------------
void BuildGroup::LoadControlSettings(const char *controlResourceName, const char *pathID, KeyValues *pPreloadedKeyValues)
{
	// make sure the file is registered
	RegisterControlSettingsFile(controlResourceName, pathID);

	// Use the keyvalues they passed in or load them.
	KeyValues *rDat = pPreloadedKeyValues;
	if ( !rDat )
	{
		// load the resource data from the file
		rDat  = new KeyValues(controlResourceName);

		// check the skins directory first, if an explicit pathID hasn't been set
		bool bSuccess = false;
		if (!pathID)
		{
			bSuccess = rDat->LoadFromFile(g_pFullFileSystem, controlResourceName, "SKIN");
		}
		if (!bSuccess)
		{
			bSuccess = rDat->LoadFromFile(g_pFullFileSystem, controlResourceName, pathID);
		}

		if ( bSuccess )
		{
			if ( IsX360() )
			{
				rDat->ProcessResolutionKeys( surface()->GetResolutionKey() );
			}
			if ( IsPC() )
			{
				ConVarRef cl_hud_minmode( "cl_hud_minmode", true );
				if ( cl_hud_minmode.IsValid() && cl_hud_minmode.GetBool() )
				{
					rDat->ProcessResolutionKeys( "_minmode" );
				}
			}
		}
	}

	// save off the resource name
	delete [] m_pResourceName;
	m_pResourceName = new char[strlen(controlResourceName) + 1];
	strcpy(m_pResourceName, controlResourceName);

	if (pathID)
	{
		delete [] m_pResourcePathID;
		m_pResourcePathID = new char[strlen(pathID) + 1];
		strcpy(m_pResourcePathID, pathID);
	}

	// delete any controls not in both files
	DeleteAllControlsCreatedByControlSettingsFile();

	// loop through the resource data sticking info into controls
	ApplySettings(rDat);

	if (m_pParentPanel)
	{
		m_pParentPanel->InvalidateLayout();
		m_pParentPanel->Repaint();
	}

	if ( rDat != pPreloadedKeyValues )
	{
		rDat->deleteThis();
	}
}
Example #30
0
bool CEngineSprite::Init( const char *pName )
{
	m_hAVIMaterial = AVIMATERIAL_INVALID;
	m_hBIKMaterial = BIKMATERIAL_INVALID;
	m_width = m_height = m_numFrames = 1;

	const char *pExt = Q_GetFileExtension( pName );
	bool bIsAVI = pExt && !Q_stricmp( pExt, "avi" );
#if !defined( _X360 ) || defined( BINK_ENABLED_FOR_X360 )
	bool bIsBIK = pExt && !Q_stricmp( pExt, "bik" );
#endif
	if ( bIsAVI && IsPC() )
	{
		m_hAVIMaterial = avi->CreateAVIMaterial( pName, pName, "GAME" );
		if ( m_hAVIMaterial == AVIMATERIAL_INVALID )
			return false;

		IMaterial *pMaterial = avi->GetMaterial( m_hAVIMaterial );
		avi->GetFrameSize( m_hAVIMaterial, &m_width, &m_height );
		m_numFrames = avi->GetFrameCount( m_hAVIMaterial );
		for ( int i = 0; i < kRenderModeCount; ++i )
		{
			m_material[i] = pMaterial;
			pMaterial->IncrementReferenceCount();
		}
	}
#if !defined( _X360 ) || defined( BINK_ENABLED_FOR_X360 )
	else if ( bIsBIK )
	{
		m_hBIKMaterial = bik->CreateMaterial( pName, pName, "GAME" );
		if ( m_hBIKMaterial == BIKMATERIAL_INVALID )
			return false;

		IMaterial *pMaterial = bik->GetMaterial( m_hBIKMaterial );
		bik->GetFrameSize( m_hBIKMaterial, &m_width, &m_height );
		m_numFrames = bik->GetFrameCount( m_hBIKMaterial );
		for ( int i = 0; i < kRenderModeCount; ++i )
		{
			m_material[i] = pMaterial;
			pMaterial->IncrementReferenceCount();
		}
	}
#endif
	else
	{
		char pTemp[MAX_PATH];
		char pMaterialName[MAX_PATH];
		char pMaterialPath[MAX_PATH];
		Q_StripExtension( pName, pTemp, sizeof(pTemp) );
		Q_strlower( pTemp );
		Q_FixSlashes( pTemp, '/' );

		// Check to see if this is a UNC-specified material name
		bool bIsUNC = pTemp[0] == '/' && pTemp[1] == '/' && pTemp[2] != '/';
		if ( !bIsUNC )
		{
			Q_strncpy( pMaterialName, "materials/", sizeof(pMaterialName) );
			Q_strncat( pMaterialName, pTemp, sizeof(pMaterialName), COPY_ALL_CHARACTERS );
		}
		else
		{
			Q_strncpy( pMaterialName, pTemp, sizeof(pMaterialName) );
		}
		Q_strncpy( pMaterialPath, pMaterialName, sizeof(pMaterialPath) );
		Q_SetExtension( pMaterialPath, ".vmt", sizeof(pMaterialPath) );

		for ( int i = 0; i < kRenderModeCount; ++i )
		{	
			m_material[i] = NULL;
		}

		KeyValues *kv = new KeyValues( "vmt" );
		if ( !kv->LoadFromFile( g_pFullFileSystem, pMaterialPath, "GAME" ) )
		{
			Warning( "Unable to load sprite material %s!\n", pMaterialPath );
			return false;
		}

		for ( int i = 0; i < kRenderModeCount; ++i )
		{	
			if ( i == kRenderNone || i == kRenderEnvironmental )
			{
				continue;
			}

			// strip possible materials/
			Q_snprintf( pMaterialPath, sizeof(pMaterialPath), "%s_rendermode_%d", pMaterialName + ( bIsUNC ? 0 : 10 ), i );
			KeyValues *pMaterialKV = kv->MakeCopy();
			pMaterialKV->SetInt( "$spriteRenderMode", i );
			m_material[i] = g_pMaterialSystem->FindProceduralMaterial( pMaterialPath, TEXTURE_GROUP_CLIENT_EFFECTS, pMaterialKV );
			m_material[i]->IncrementReferenceCount();	
		}

		kv->deleteThis();

		m_width = m_material[0]->GetMappingWidth();
		m_height = m_material[0]->GetMappingHeight();
		m_numFrames = m_material[0]->GetNumAnimationFrames();
	}

	for ( int i = 0; i < kRenderModeCount; ++i )
	{
		if ( i == kRenderNone || i == kRenderEnvironmental )
			continue;

		if ( !m_material[i] )
			return false;
	}

	IMaterialVar *orientationVar = m_material[0]->FindVarFast( "$spriteorientation", &spriteOrientationCache );
	m_orientation = orientationVar ? orientationVar->GetIntValue() : C_SpriteRenderer::SPR_VP_PARALLEL_UPRIGHT;

	IMaterialVar *originVar = m_material[0]->FindVarFast( "$spriteorigin", &spriteOriginCache );
	Vector origin, originVarValue;
	if( !originVar || ( originVar->GetType() != MATERIAL_VAR_TYPE_VECTOR ) )
	{
		origin[0] = -m_width * 0.5f;
		origin[1] = m_height * 0.5f;
	}
	else
	{
		originVar->GetVecValue( &originVarValue[0], 3 );
		origin[0] = -m_width * originVarValue[0];
		origin[1] = m_height * originVarValue[1];
	}

	up = origin[1];
	down = origin[1] - m_height;
	left = origin[0];
	right = m_width + origin[0];

	return true;
}