// first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that HScheme CSchemeManager::LoadSchemeFromFileEx( VPANEL sizingPanel, const char *fileName, const char *tag) { // Look to see if we've already got this scheme... HScheme hScheme = FindLoadedScheme(fileName); if (hScheme != 0) { CScheme *pScheme = static_cast< CScheme * >( GetIScheme( hScheme ) ); if ( IsPC() && pScheme ) { pScheme->ReloadFontGlyphs(); } return hScheme; } KeyValues *data; data = new KeyValues("Scheme"); data->UsesEscapeSequences( true ); // VGUI uses this // look first in skins directory bool result = data->LoadFromFile( g_pFullFileSystem, fileName, "SKIN" ); if (!result) { result = data->LoadFromFile( g_pFullFileSystem, fileName, "GAME" ); if ( !result ) { // look in any directory result = data->LoadFromFile( g_pFullFileSystem, fileName, NULL ); } } if (!result) { data->deleteThis(); return 0; } if ( IsX360() ) { data->ProcessResolutionKeys( g_pSurface->GetResolutionKey() ); } if ( IsPC() ) { ConVarRef cl_hud_minmode( "cl_hud_minmode", true ); if ( cl_hud_minmode.IsValid() && cl_hud_minmode.GetBool() ) { data->ProcessResolutionKeys( "_minmode" ); } } CScheme *newScheme = new CScheme(); newScheme->LoadFromFile( sizingPanel, fileName, tag, data ); return m_Schemes.AddToTail(newScheme); }
// Load the control settings void CBaseModFrame::LoadControlSettings( const char *dialogResourceName, const char *pathID, KeyValues *pPreloadedKeyValues, KeyValues *pConditions ) { // Use the keyvalues they passed in or load them using special hook for flyouts generation KeyValues *rDat = pPreloadedKeyValues; if ( !rDat ) { // load the resource data from the file rDat = new KeyValues(dialogResourceName); // check the skins directory first, if an explicit pathID hasn't been set bool bSuccess = false; if ( !IsX360() && !pathID ) { bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, "SKIN" ); } if ( !bSuccess ) { bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, pathID ); } if ( bSuccess ) { if ( IsX360() ) { rDat->ProcessResolutionKeys( surface()->GetResolutionKey() ); } if ( pConditions && pConditions->GetFirstSubKey() ) { GetBuildGroup()->ProcessConditionalKeys( rDat, pConditions ); } } } // Find the auto-generated-chapter hook if ( KeyValues *pHook = rDat->FindKey( "FlmChapterXXautogenerated" ) ) { const int numMaxAutogeneratedFlyouts = 20; for ( int k = 1; k <= numMaxAutogeneratedFlyouts; ++ k ) { KeyValues *pFlyoutInfo = pHook->MakeCopy(); CFmtStr strName( "FlmChapter%d", k ); pFlyoutInfo->SetName( strName ); pFlyoutInfo->SetString( "fieldName", strName ); pFlyoutInfo->SetString( "ResourceFile", CFmtStr( "FlmChapterXXautogenerated_%d/%s", k, pHook->GetString( "ResourceFile" ) ) ); rDat->AddSubKey( pFlyoutInfo ); } rDat->RemoveSubKey( pHook ); pHook->deleteThis(); } BaseClass::LoadControlSettings( dialogResourceName, pathID, rDat, pConditions ); if ( rDat != pPreloadedKeyValues ) { rDat->deleteThis(); } }
bool KeyValues::ProcessResolutionKeys(const char *pResString) { if (!pResString) return false; KeyValues *pSubKey = GetFirstSubKey(); if (!pSubKey) return false; for ( ; pSubKey != NULL; pSubKey = pSubKey->GetNextKey()) { pSubKey->ProcessResolutionKeys(pResString); if (Q_stristr(pSubKey->GetName(), pResString) != NULL) { char normalKeyName[128]; V_strncpy(normalKeyName, pSubKey->GetName(), sizeof(normalKeyName)); char *pString = Q_stristr(normalKeyName, pResString); if (pString && !Q_stricmp(pString, pResString)) { *pString = '\0'; KeyValues *pKey = FindKey(normalKeyName); if (pKey) { RemoveSubKey(pKey); } pSubKey->SetName(normalKeyName); } } } return true; }
//----------------------------------------------------------------------------- // 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(); } }