Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

598 lines
18 KiB

  1. //========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: VPC
  4. //
  5. //=====================================================================================//
  6. #include "vpc.h"
  7. #define PROPERTYNAME( X, Y ) { X##_##Y, #X, #Y },
  8. static PropertyName_t s_Xbox360PropertyNames_2010[] =
  9. {
  10. #include "projectgenerator_xbox360_2010.inc"
  11. { -1, NULL, NULL }
  12. };
  13. IBaseProjectGenerator* GetXbox360ProjectGenerator_2010()
  14. {
  15. static CProjectGenerator_Xbox360_2010 *s_pProjectGenerator = NULL;
  16. if ( !s_pProjectGenerator )
  17. {
  18. s_pProjectGenerator = new CProjectGenerator_Xbox360_2010();
  19. }
  20. return s_pProjectGenerator->GetProjectGenerator();
  21. }
  22. CProjectGenerator_Xbox360_2010::CProjectGenerator_Xbox360_2010()
  23. {
  24. m_pVCProjGenerator = new CVCProjGenerator();
  25. m_pVCProjGenerator->SetupGeneratorDefinition( this, "xbox360_2010.def", s_Xbox360PropertyNames_2010 );
  26. }
  27. enum TypeKeyNames_e
  28. {
  29. TKN_LIBRARY = 0,
  30. TKN_INCLUDE,
  31. TKN_COMPILE,
  32. TKN_RESOURCECOMPILE,
  33. TKN_CUSTOMBUILD,
  34. TKN_NONE,
  35. TKN_MAX_COUNT,
  36. };
  37. static const char *s_TypeKeyNames[] =
  38. {
  39. "Library",
  40. "ClInclude",
  41. "ClCompile",
  42. "ResourceCompile",
  43. "CustomBuild",
  44. "None"
  45. };
  46. const char *CProjectGenerator_Xbox360_2010::GetKeyNameForFile( CProjectFile *pFile )
  47. {
  48. COMPILE_TIME_ASSERT( ARRAYSIZE( s_TypeKeyNames ) == TKN_MAX_COUNT );
  49. const char *pExtension = V_GetFileExtension( pFile->m_Name.Get() );
  50. const char *pKeyName = s_TypeKeyNames[TKN_NONE];
  51. if ( pExtension )
  52. {
  53. if ( !V_stricmp( pExtension, "cpp" ) || !V_stricmp( pExtension, "cxx" ) || !V_stricmp( pExtension, "c" ) || !V_stricmp( pExtension, "cc" ) )
  54. {
  55. pKeyName = s_TypeKeyNames[TKN_COMPILE];
  56. }
  57. else if ( !V_stricmp( pExtension, "h" ) || !V_stricmp( pExtension, "hxx" ) )
  58. {
  59. pKeyName = s_TypeKeyNames[TKN_INCLUDE];
  60. }
  61. else if ( !V_stricmp( pExtension, "lib" ) )
  62. {
  63. pKeyName = s_TypeKeyNames[TKN_LIBRARY];
  64. }
  65. else if ( !V_stricmp( pExtension, "rc" ) )
  66. {
  67. pKeyName = s_TypeKeyNames[TKN_RESOURCECOMPILE];
  68. }
  69. else
  70. {
  71. if ( pFile->m_Configs.Count() && pFile->m_Configs[0]->GetCustomBuildTool() )
  72. {
  73. pKeyName = s_TypeKeyNames[TKN_CUSTOMBUILD];
  74. }
  75. }
  76. }
  77. return pKeyName;
  78. }
  79. bool CProjectGenerator_Xbox360_2010::WritePropertyGroupTool( CProjectTool *pProjectTool, CProjectConfiguration *pConfiguration )
  80. {
  81. if ( !pProjectTool )
  82. return true;
  83. for ( int i = 0; i < pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  84. {
  85. int sortedIndex = pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder[i];
  86. if ( !pProjectTool->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  87. continue;
  88. if ( !WriteProperty( &pProjectTool->m_PropertyStates.m_Properties[sortedIndex], true, pConfiguration->m_Name.Get() ) )
  89. return false;
  90. }
  91. return true;
  92. }
  93. bool CProjectGenerator_Xbox360_2010::WriteFile( CProjectFile *pFile, const char *pFileTypeName )
  94. {
  95. const char *pKeyName = GetKeyNameForFile( pFile );
  96. if ( V_stricmp( pFileTypeName, pKeyName ) )
  97. {
  98. // skip it
  99. return true;
  100. }
  101. if ( !pFile->m_Configs.Count() )
  102. {
  103. m_XMLWriter.Write( CFmtStrMax( "<%s Include=\"%s\" />", pKeyName, pFile->m_Name.Get() ) );
  104. }
  105. else
  106. {
  107. m_XMLWriter.PushNode( pKeyName, CFmtStr( "Include=\"%s\"", pFile->m_Name.Get() ) );
  108. for ( int i = 0; i < pFile->m_Configs.Count(); i++ )
  109. {
  110. if ( !WriteConfiguration( pFile->m_Configs[i] ) )
  111. return false;
  112. }
  113. m_XMLWriter.PopNode( true );
  114. }
  115. return true;
  116. }
  117. bool CProjectGenerator_Xbox360_2010::WriteFolder( CProjectFolder *pFolder, const char *pFileTypeName, int nDepth )
  118. {
  119. if ( !nDepth )
  120. {
  121. m_XMLWriter.PushNode( "ItemGroup" );
  122. }
  123. for ( int iIndex = pFolder->m_Files.Head(); iIndex != pFolder->m_Files.InvalidIndex(); iIndex = pFolder->m_Files.Next( iIndex ) )
  124. {
  125. if ( !WriteFile( pFolder->m_Files[iIndex], pFileTypeName ) )
  126. return false;
  127. }
  128. for ( int iIndex = pFolder->m_Folders.Head(); iIndex != pFolder->m_Folders.InvalidIndex(); iIndex = pFolder->m_Folders.Next( iIndex ) )
  129. {
  130. if ( !WriteFolder( pFolder->m_Folders[iIndex], pFileTypeName, nDepth+1 ) )
  131. return false;
  132. }
  133. if ( !nDepth )
  134. {
  135. m_XMLWriter.PopNode( true );
  136. }
  137. return true;
  138. }
  139. bool CProjectGenerator_Xbox360_2010::WriteConfiguration( CProjectConfiguration *pConfig )
  140. {
  141. if ( !pConfig->m_bIsFileConfig )
  142. {
  143. m_XMLWriter.PushNode( "PropertyGroup", CFmtStr( "Condition=\"'$(Configuration)|$(Platform)'=='%s|Xbox 360'\" Label=\"Configuration\"", pConfig->m_Name.Get() ) );
  144. for ( int i = 0; i < pConfig->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  145. {
  146. int sortedIndex = pConfig->m_PropertyStates.m_PropertiesInOutputOrder[i];
  147. if ( pConfig->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  148. continue;
  149. if ( !WriteProperty( &pConfig->m_PropertyStates.m_Properties[sortedIndex] ) )
  150. return false;
  151. }
  152. WriteProperty( NULL, false, NULL, "UseOfAtl", "false" );
  153. m_XMLWriter.PopNode( true );
  154. }
  155. else
  156. {
  157. for ( int i = 0; i < pConfig->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  158. {
  159. int sortedIndex = pConfig->m_PropertyStates.m_PropertiesInOutputOrder[i];
  160. if ( !WriteProperty( &pConfig->m_PropertyStates.m_Properties[sortedIndex], true, pConfig->m_Name.Get() ) )
  161. return false;
  162. }
  163. if ( !WriteTool( "ClCompile", pConfig->GetCompilerTool(), pConfig ) )
  164. return false;
  165. if ( !WriteTool( "CustomBuildStep", pConfig->GetCustomBuildTool(), pConfig ) )
  166. return false;
  167. }
  168. return true;
  169. }
  170. bool CProjectGenerator_Xbox360_2010::WriteTools( CProjectConfiguration *pConfig )
  171. {
  172. m_XMLWriter.PushNode( "ItemDefinitionGroup", CFmtStr( "Condition=\"'$(Configuration)|$(Platform)'=='%s|Xbox 360'\"", pConfig->m_Name.Get() ) );
  173. if ( !WriteTool( "PreBuildEvent", pConfig->GetPreBuildEventTool(), pConfig ) )
  174. return false;
  175. if ( !WriteTool( "CustomBuildStep", pConfig->GetCustomBuildTool(), pConfig ) )
  176. return false;
  177. if ( !WriteTool( "ClCompile", pConfig->GetCompilerTool(), pConfig ) )
  178. return false;
  179. if ( !WriteTool( "PreLinkEvent", pConfig->GetPreLinkEventTool(), pConfig ) )
  180. return false;
  181. if ( !WriteTool( "Link", pConfig->GetLinkerTool(), pConfig ) )
  182. return false;
  183. if ( !WriteTool( "Lib", pConfig->GetLibrarianTool(), pConfig ) )
  184. return false;
  185. if ( !WriteTool( "ImageXex", pConfig->GetXboxImageTool(), pConfig ) )
  186. return false;
  187. if ( !WriteTool( "Bscmake", pConfig->GetBrowseInfoTool(), pConfig ) )
  188. return false;
  189. if ( !WriteTool( "Deploy", pConfig->GetXboxDeploymentTool(), pConfig ) )
  190. return false;
  191. if ( !WriteTool( "PostBuildEvent", pConfig->GetPostBuildEventTool(), pConfig ) )
  192. return false;
  193. m_XMLWriter.PopNode( true );
  194. return true;
  195. }
  196. bool CProjectGenerator_Xbox360_2010::WritePrimaryXML( const char *pOutputFilename )
  197. {
  198. if ( !m_XMLWriter.Open( pOutputFilename, true ) )
  199. return false;
  200. m_XMLWriter.PushNode( "Project", "DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"" );
  201. m_XMLWriter.PushNode( "ItemGroup", "Label=\"ProjectConfigurations\"" );
  202. CUtlVector< CUtlString > configurationNames;
  203. m_pVCProjGenerator->GetAllConfigurationNames( configurationNames );
  204. for ( int i = 0; i < configurationNames.Count(); i++ )
  205. {
  206. m_XMLWriter.PushNode( "ProjectConfiguration", CFmtStr( "Include=\"%s|Xbox 360\"", configurationNames[i].Get() ) );
  207. m_XMLWriter.WriteLineNode( "Configuration", "", configurationNames[i].Get() );
  208. m_XMLWriter.WriteLineNode( "Platform", "", "Xbox 360" );
  209. m_XMLWriter.PopNode( true );
  210. }
  211. m_XMLWriter.PopNode( true );
  212. m_XMLWriter.PushNode( "PropertyGroup", "Label=\"Globals\"" );
  213. m_XMLWriter.WriteLineNode( "ProjectName", "", m_pVCProjGenerator->GetProjectName().Get() );
  214. m_XMLWriter.WriteLineNode( "ProjectGuid", "", m_pVCProjGenerator->GetGUIDString().Get() );
  215. m_XMLWriter.PopNode( true );
  216. m_XMLWriter.Write( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />" );
  217. // write the root configurations
  218. for ( int i = 0; i < configurationNames.Count(); i++ )
  219. {
  220. CProjectConfiguration *pConfiguration = NULL;
  221. if ( m_pVCProjGenerator->GetRootConfiguration( configurationNames[i].Get(), &pConfiguration ) )
  222. {
  223. if ( !WriteConfiguration( pConfiguration ) )
  224. return false;
  225. }
  226. }
  227. m_XMLWriter.Write( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />" );
  228. m_XMLWriter.PushNode( "ImportGroup", "Label=\"ExtensionSettings\"" );
  229. m_XMLWriter.PopNode( true );
  230. for ( int i = 0; i < configurationNames.Count(); i++ )
  231. {
  232. m_XMLWriter.PushNode( "ImportGroup", CFmtStr( "Condition=\"'$(Configuration)|$(Platform)'=='%s|Xbox 360'\" Label=\"PropertySheets\"", configurationNames[i].Get() ) );
  233. m_XMLWriter.Write( "<Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />" );
  234. m_XMLWriter.PopNode( true );
  235. }
  236. m_XMLWriter.Write( "<PropertyGroup Label=\"UserMacros\" />" );
  237. m_XMLWriter.PushNode( "PropertyGroup" );
  238. m_XMLWriter.WriteLineNode( "_ProjectFileVersion", "", "10.0.30319.1" );
  239. for ( int i = 0; i < configurationNames.Count(); i++ )
  240. {
  241. CProjectConfiguration *pConfiguration = NULL;
  242. if ( m_pVCProjGenerator->GetRootConfiguration( configurationNames[i].Get(), &pConfiguration ) )
  243. {
  244. for ( int j = 0; j < pConfiguration->m_PropertyStates.m_PropertiesInOutputOrder.Count(); j++ )
  245. {
  246. int sortedIndex = pConfiguration->m_PropertyStates.m_PropertiesInOutputOrder[j];
  247. if ( !pConfiguration->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  248. continue;
  249. if ( !WriteProperty( &pConfiguration->m_PropertyStates.m_Properties[sortedIndex], true, pConfiguration->m_Name.Get() ) )
  250. return false;
  251. }
  252. if ( !WritePropertyGroupTool( pConfiguration->GetPreBuildEventTool(), pConfiguration ) )
  253. return false;
  254. if ( !WritePropertyGroupTool( pConfiguration->GetPreLinkEventTool(), pConfiguration ) )
  255. return false;
  256. if ( !WritePropertyGroupTool( pConfiguration->GetLinkerTool(), pConfiguration ) )
  257. return false;
  258. if ( !WritePropertyGroupTool( pConfiguration->GetLibrarianTool(), pConfiguration ) )
  259. return false;
  260. if ( !WritePropertyGroupTool( pConfiguration->GetPostBuildEventTool(), pConfiguration ) )
  261. return false;
  262. if ( !WritePropertyGroupTool( pConfiguration->GetXboxImageTool(), pConfiguration ) )
  263. return false;
  264. if ( !WritePropertyGroupTool( pConfiguration->GetXboxDeploymentTool(), pConfiguration ) )
  265. return false;
  266. }
  267. }
  268. m_XMLWriter.PopNode( true );
  269. // write the tool configurations
  270. for ( int i = 0; i < configurationNames.Count(); i++ )
  271. {
  272. CProjectConfiguration *pConfiguration = NULL;
  273. if ( m_pVCProjGenerator->GetRootConfiguration( configurationNames[i].Get(), &pConfiguration ) )
  274. {
  275. if ( !WriteTools( pConfiguration ) )
  276. return false;
  277. }
  278. }
  279. // write root folders
  280. for ( int i = 0; i < TKN_MAX_COUNT; i++ )
  281. {
  282. if ( !WriteFolder( m_pVCProjGenerator->GetRootFolder(), s_TypeKeyNames[i], 0 ) )
  283. return false;
  284. }
  285. m_XMLWriter.Write( "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />" );
  286. m_XMLWriter.PushNode( "ImportGroup", "Label=\"ExtensionTargets\"" );
  287. m_XMLWriter.PopNode( true );
  288. m_XMLWriter.PopNode( true );
  289. m_XMLWriter.Close();
  290. return true;
  291. }
  292. bool CProjectGenerator_Xbox360_2010::WriteFolderToSecondaryXML( CProjectFolder *pFolder, const char *pParentPath )
  293. {
  294. CUtlString parentPath = CFmtStr( "%s%s%s", pParentPath, pParentPath[0] ? "\\" : "", pFolder->m_Name.Get() );
  295. MD5Context_t ctx;
  296. unsigned char digest[MD5_DIGEST_LENGTH];
  297. V_memset( &ctx, 0, sizeof( ctx ) );
  298. V_memset( digest, 0, sizeof( digest ) );
  299. MD5Init( &ctx );
  300. MD5Update( &ctx, (unsigned char *)parentPath.Get(), strlen( parentPath.Get() ) );
  301. MD5Final( digest, &ctx );
  302. char szMD5[64];
  303. V_binarytohex( digest, MD5_DIGEST_LENGTH, szMD5, sizeof( szMD5 ) );
  304. V_strupr( szMD5 );
  305. char szGUID[MAX_PATH];
  306. V_snprintf( szGUID, sizeof( szGUID ), "{%8.8s-%4.4s-%4.4s-%4.4s-%12.12s}", szMD5, &szMD5[8], &szMD5[12], &szMD5[16], &szMD5[20] );
  307. m_XMLFilterWriter.PushNode( "Filter", CFmtStr( "Include=\"%s\"", parentPath.Get() ) );
  308. m_XMLFilterWriter.WriteLineNode( "UniqueIdentifier", "", szGUID );
  309. m_XMLFilterWriter.PopNode( true );
  310. for ( int iIndex = pFolder->m_Folders.Head(); iIndex != pFolder->m_Folders.InvalidIndex(); iIndex = pFolder->m_Folders.Next( iIndex ) )
  311. {
  312. if ( !WriteFolderToSecondaryXML( pFolder->m_Folders[iIndex], parentPath.Get() ) )
  313. return false;
  314. }
  315. return true;
  316. }
  317. bool CProjectGenerator_Xbox360_2010::WriteFileToSecondaryXML( CProjectFile *pFile, const char *pParentPath, const char *pFileTypeName )
  318. {
  319. const char *pKeyName = GetKeyNameForFile( pFile );
  320. if ( V_stricmp( pFileTypeName, pKeyName ) )
  321. {
  322. // skip it
  323. return true;
  324. }
  325. if ( pParentPath )
  326. {
  327. m_XMLFilterWriter.PushNode( pKeyName, CFmtStr( "Include=\"%s\"", pFile->m_Name.Get() ) );
  328. m_XMLFilterWriter.WriteLineNode( "Filter", "", pParentPath );
  329. m_XMLFilterWriter.PopNode( true );
  330. }
  331. else
  332. {
  333. m_XMLFilterWriter.Write( CFmtStr( "<%s Include=\"%s\" />", pKeyName, pFile->m_Name.Get() ) );
  334. }
  335. return true;
  336. }
  337. bool CProjectGenerator_Xbox360_2010::WriteFolderContentsToSecondaryXML( CProjectFolder *pFolder, const char *pParentPath, const char *pFileTypeName, int nDepth )
  338. {
  339. CUtlString parentPath;
  340. if ( pParentPath )
  341. {
  342. parentPath = CFmtStr( "%s%s%s", pParentPath, pParentPath[0] ? "\\" : "", pFolder->m_Name.Get() );
  343. }
  344. if ( !nDepth )
  345. {
  346. m_XMLFilterWriter.PushNode( "ItemGroup", NULL );
  347. }
  348. for ( int iIndex = pFolder->m_Files.Head(); iIndex != pFolder->m_Files.InvalidIndex(); iIndex = pFolder->m_Files.Next( iIndex ) )
  349. {
  350. if ( !WriteFileToSecondaryXML( pFolder->m_Files[iIndex], parentPath.Get(), pFileTypeName ) )
  351. return false;
  352. }
  353. for ( int iIndex = pFolder->m_Folders.Head(); iIndex != pFolder->m_Folders.InvalidIndex(); iIndex = pFolder->m_Folders.Next( iIndex ) )
  354. {
  355. if ( !WriteFolderContentsToSecondaryXML( pFolder->m_Folders[iIndex], parentPath.Get(), pFileTypeName, nDepth+1 ) )
  356. return false;
  357. }
  358. if ( !nDepth )
  359. {
  360. m_XMLFilterWriter.PopNode( true );
  361. }
  362. return true;
  363. }
  364. bool CProjectGenerator_Xbox360_2010::WriteSecondaryXML( const char *pOutputFilename )
  365. {
  366. if ( !m_XMLFilterWriter.Open( pOutputFilename, true ) )
  367. return false;
  368. m_XMLFilterWriter.PushNode( "Project", "ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\"" );
  369. // write the root folders
  370. m_XMLFilterWriter.PushNode( "ItemGroup", NULL );
  371. CProjectFolder *pRootFolder = m_pVCProjGenerator->GetRootFolder();
  372. for ( int iIndex = pRootFolder->m_Folders.Head(); iIndex != pRootFolder->m_Folders.InvalidIndex(); iIndex = pRootFolder->m_Folders.Next( iIndex ) )
  373. {
  374. if ( !WriteFolderToSecondaryXML( pRootFolder->m_Folders[iIndex], "" ) )
  375. return false;
  376. }
  377. m_XMLFilterWriter.PopNode( true );
  378. // write folder contents
  379. for ( int i = 0; i < TKN_MAX_COUNT; i++ )
  380. {
  381. if ( !WriteFolderContentsToSecondaryXML( pRootFolder, NULL, s_TypeKeyNames[i], 0 ) )
  382. return false;
  383. }
  384. m_XMLFilterWriter.PopNode( true );
  385. m_XMLFilterWriter.Close();
  386. return true;
  387. }
  388. bool CProjectGenerator_Xbox360_2010::WriteTool( const char *pToolName, const CProjectTool *pProjectTool, CProjectConfiguration *pConfig )
  389. {
  390. if ( !pProjectTool )
  391. {
  392. // not an error, some tools n/a for a config
  393. return true;
  394. }
  395. if ( !pConfig->m_bIsFileConfig )
  396. {
  397. m_XMLWriter.PushNode( pToolName, NULL );
  398. }
  399. for ( int i = 0; i < pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder.Count(); i++ )
  400. {
  401. int sortedIndex = pProjectTool->m_PropertyStates.m_PropertiesInOutputOrder[i];
  402. if ( !pConfig->m_bIsFileConfig )
  403. {
  404. if ( pProjectTool->m_PropertyStates.m_Properties[sortedIndex].m_pToolProperty->m_bEmitAsGlobalProperty )
  405. continue;
  406. if ( !WriteProperty( &pProjectTool->m_PropertyStates.m_Properties[sortedIndex] ) )
  407. return false;
  408. }
  409. else
  410. {
  411. if ( !WriteProperty( &pProjectTool->m_PropertyStates.m_Properties[sortedIndex], true, pConfig->m_Name.Get() ) )
  412. return false;
  413. }
  414. }
  415. if ( !pConfig->m_bIsFileConfig )
  416. {
  417. m_XMLWriter.PopNode( true );
  418. }
  419. return true;
  420. }
  421. bool CProjectGenerator_Xbox360_2010::WriteProperty( const PropertyState_t *pPropertyState, bool bEmitConfiguration, const char *pConfigName, const char *pOutputName, const char *pOutputValue )
  422. {
  423. if ( !pPropertyState )
  424. {
  425. m_XMLWriter.WriteLineNode( pOutputName, "", pOutputValue );
  426. return true;
  427. }
  428. if ( !pOutputName )
  429. {
  430. pOutputName = pPropertyState->m_pToolProperty->m_OutputString.Get();
  431. if ( !pOutputName[0] )
  432. {
  433. pOutputName = pPropertyState->m_pToolProperty->m_ParseString.Get();
  434. if ( pOutputName[0] == '$' )
  435. {
  436. pOutputName++;
  437. }
  438. }
  439. }
  440. const char *pCondition = "";
  441. CUtlString conditionString;
  442. if ( bEmitConfiguration )
  443. {
  444. conditionString = CFmtStr( " Condition=\"'$(Configuration)|$(Platform)'=='%s|Xbox 360'\"", pConfigName );
  445. pCondition = conditionString.Get();
  446. }
  447. if ( pPropertyState )
  448. {
  449. switch ( pPropertyState->m_pToolProperty->m_nType )
  450. {
  451. case PT_BOOLEAN:
  452. {
  453. bool bEnabled = Sys_StringToBool( pPropertyState->m_StringValue.Get() );
  454. if ( pPropertyState->m_pToolProperty->m_bInvertOutput )
  455. {
  456. bEnabled ^= 1;
  457. }
  458. m_XMLWriter.WriteLineNode( pOutputName, pCondition, bEnabled ? "true" : "false" );
  459. }
  460. break;
  461. case PT_STRING:
  462. m_XMLWriter.WriteLineNode( pOutputName, pCondition, m_XMLWriter.FixupXMLString( pPropertyState->m_StringValue.Get() ) );
  463. break;
  464. case PT_LIST:
  465. case PT_INTEGER:
  466. m_XMLWriter.WriteLineNode( pOutputName, pCondition, pPropertyState->m_StringValue.Get() );
  467. break;
  468. case PT_IGNORE:
  469. break;
  470. default:
  471. g_pVPC->VPCError( "CProjectGenerator_Xbox360_2010: WriteProperty, %s - not implemented", pOutputName );
  472. }
  473. }
  474. return true;
  475. }
  476. bool CProjectGenerator_Xbox360_2010::Save( const char *pOutputFilename )
  477. {
  478. bool bValid = WritePrimaryXML( pOutputFilename );
  479. if ( bValid )
  480. {
  481. bValid = WriteSecondaryXML( CFmtStr( "%s.filters", pOutputFilename ) );
  482. if ( !bValid )
  483. {
  484. g_pVPC->VPCError( "Cannot save to the specified project '%s'", pOutputFilename );
  485. }
  486. }
  487. return bValid;
  488. }