Team Fortress 2 Source Code as on 22/4/2020
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.

1357 lines
46 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "ModWizard_Intro.h"
  7. #include "ModWizard_TemplateOptions.h"
  8. #include "ModWizard_CopyFiles.h"
  9. #include "ModWizard_Finished.h"
  10. #include "CreateModWizard.h"
  11. #include "configs.h"
  12. #include "filesystem_tools.h"
  13. #include "sdklauncher_main.h"
  14. #include "SDKLauncherDialog.h"
  15. #include <vgui_controls/WizardPanel.h>
  16. #include <vgui/ivgui.h>
  17. #include "SourceAppInfo.h"
  18. using namespace vgui;
  19. extern bool IsGameSubscribed( int nSteamAppId );
  20. extern char g_engineDir[50];
  21. class CTempDirectory
  22. {
  23. public:
  24. char m_FullName[MAX_PATH];
  25. char m_FullOutName[MAX_PATH];
  26. };
  27. CModWizardSubPanel_CopyFiles::CModWizardSubPanel_CopyFiles( Panel *parent, const char *panelName )
  28. : BaseClass( parent, panelName )
  29. {
  30. m_pLabel = new Label( this, "MessageLabel", "" );
  31. m_pFinishedLabel = new Label( this, "FinishedLabel", "" );
  32. m_pProgressBar = new ProgressBar( this, "CopyProgressBar" );
  33. m_pProgressBar->SetProgress( 0 );
  34. LoadControlSettings( "ModWizardSubPanel_CopyFiles.res");
  35. }
  36. void CModWizardSubPanel_CopyFiles::OnDisplayAsNext()
  37. {
  38. GetWizardPanel()->SetTitle( "#ModWizard_CopyFiles_Title", true );
  39. m_iCurCopyFile = -1;
  40. // All buttons are disabled until we're done.
  41. GetWizardPanel()->SetCancelButtonEnabled( false );
  42. GetWizardPanel()->SetFinishButtonEnabled( false );
  43. GetWizardPanel()->SetPrevButtonEnabled( false );
  44. GetWizardPanel()->SetNextButtonEnabled( false );
  45. ivgui()->AddTickSignal( GetVPanel() );
  46. }
  47. WizardSubPanel *CModWizardSubPanel_CopyFiles::GetNextSubPanel()
  48. {
  49. return dynamic_cast<WizardSubPanel *>(GetWizardPanel()->FindChildByName("CModWizardSubPanel_Finished"));
  50. }
  51. void CModWizardSubPanel_CopyFiles::GetReady( const char *pOutputDirName, const char *pOutputModGamedirName, const char *modName )
  52. {
  53. Q_strncpy( m_OutputDirName, pOutputDirName, sizeof( m_OutputDirName ) );
  54. Q_strncpy( m_OutModGamedirName, pOutputModGamedirName, sizeof( m_OutModGamedirName ) );
  55. Q_strncpy( m_ModName, modName, sizeof( m_ModName ) );
  56. }
  57. // Creates the directory structure and builds a list of files to copy.
  58. bool CModWizardSubPanel_CopyFiles::BuildCopyFiles_R( const char *pSourceDir, const char *pMask, const char *pOutputDirName )
  59. {
  60. char mask[512];
  61. Q_snprintf( mask, sizeof( mask ), "%s%c%s", pSourceDir, CORRECT_PATH_SEPARATOR, pMask );
  62. // Steam only allows 5 Find handles open at one time, and
  63. // we actually will hit the limit if we recurse into directories while looping through the files.
  64. CUtlVector<CTempDirectory> directories;
  65. FileFindHandle_t findHandle;
  66. const char *pFilename = g_pFullFileSystem->FindFirstEx( mask, 0, &findHandle );
  67. while ( pFilename )
  68. {
  69. // Skip the "." and ".." directories.
  70. if ( pFilename[0] != '.' )
  71. {
  72. char fullName[MAX_PATH];
  73. Q_snprintf( fullName, sizeof( fullName ), "%s%c%s", pSourceDir, CORRECT_PATH_SEPARATOR, pFilename );
  74. char fullOutName[MAX_PATH];
  75. Q_snprintf( fullOutName, sizeof( fullOutName ), "%s%c%s", pOutputDirName, CORRECT_PATH_SEPARATOR, pFilename );
  76. // We were doing this for Linux but disabled it.
  77. //Q_strlower( fullOutName );
  78. // Recurse into other directories.
  79. if ( g_pFullFileSystem->FindIsDirectory( findHandle ) )
  80. {
  81. CTempDirectory *pBlah = &directories[directories.AddToTail()];
  82. Q_strncpy( pBlah->m_FullName, fullName, sizeof( pBlah->m_FullName ) );
  83. Q_strncpy( pBlah->m_FullOutName, fullOutName, sizeof( pBlah->m_FullOutName ) );
  84. }
  85. else
  86. {
  87. // Don't copy .dsp files.
  88. const char *pIgnoreExtension = ".dsp";
  89. char ext[512];
  90. Q_StrRight( pFilename, strlen(pIgnoreExtension), ext, sizeof( ext ) );
  91. if ( Q_stricmp( ext, pIgnoreExtension ) != 0 )
  92. {
  93. CFileCopyInfo info( fullName, fullOutName );
  94. m_FileCopyInfos.AddToTail( info );
  95. }
  96. }
  97. }
  98. pFilename = g_pFullFileSystem->FindNext( findHandle );
  99. }
  100. g_pFullFileSystem->FindClose( findHandle );
  101. // See the definition of directories for why we do this.
  102. for ( int i=0; i < directories.Count(); i++ )
  103. {
  104. // Make sure the directory exists.
  105. CTempDirectory *pDir = &directories[i];
  106. if ( !CreateFullDirectory( pDir->m_FullOutName ) )
  107. {
  108. VGUIMessageBox( this, "Error", "Can't create directory: %s", pDir->m_FullOutName );
  109. return false;
  110. }
  111. if ( !BuildCopyFiles_R( pDir->m_FullName, pMask, pDir->m_FullOutName ) )
  112. return false;
  113. }
  114. return true;
  115. }
  116. bool CModWizardSubPanel_CopyFiles::BuildCopyFilesForMappings( char **pMappings, int nMappings )
  117. {
  118. for ( int iDir=0; iDir < nMappings; iDir+=3 )
  119. {
  120. if ( !BuildCopyFiles_R( pMappings[iDir+0], pMappings[iDir+1], pMappings[iDir+2] ) )
  121. {
  122. vgui::ivgui()->RemoveTickSignal( GetVPanel() );
  123. GetWizardPanel()->SetCancelButtonEnabled( true );
  124. return false;
  125. }
  126. }
  127. return true;
  128. }
  129. bool CModWizardSubPanel_CopyFiles_Source2006::BuildCopyFilesForMod_HL2()
  130. {
  131. bool retVal = false;
  132. char outputSrcDirName[MAX_PATH];
  133. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  134. char outputUIDir[MAX_PATH], outputResourceDir[MAX_PATH], outputScriptsDir[MAX_PATH];
  135. Q_snprintf( outputUIDir, sizeof( outputUIDir ), "%sResource%cUI", m_OutModGamedirName, CORRECT_PATH_SEPARATOR );
  136. Q_snprintf( outputResourceDir, sizeof( outputResourceDir ), "%sresource", m_OutModGamedirName );
  137. Q_snprintf( outputScriptsDir, sizeof( outputScriptsDir ), "%sscripts", m_OutModGamedirName );
  138. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  139. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  140. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  141. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  142. // These go in c:\mymod
  143. char *sources_mappings[] =
  144. {
  145. "src_mod\\ep1", "*.*", outputSrcDirName
  146. };
  147. char outputGamedirNameNoSlash[MAX_PATH];
  148. Q_strncpy( outputGamedirNameNoSlash, m_OutModGamedirName, sizeof( outputGamedirNameNoSlash ) );
  149. if ( strlen( outputGamedirNameNoSlash ) > 0 )
  150. outputGamedirNameNoSlash[strlen(outputGamedirNameNoSlash)-1] = 0;
  151. // These go in c:\steam\steamapps\sourcemods\modname
  152. char *content_mappings[] =
  153. {
  154. "game_content\\half-life 2\\hl2","lights.rad", outputGamedirNameNoSlash,
  155. "game_content\\half-life 2\\hl2","detail.vbsp", outputGamedirNameNoSlash,
  156. "hl2\\scripts", "*.*", outputScriptsDir,
  157. "hl2\\resource\\ui","*.*", outputUIDir,
  158. "hl2\\resource", "clientscheme.res", outputResourceDir,
  159. "hl2\\resource", "combinepanelscheme.res", outputResourceDir,
  160. "hl2\\resource", "gameevents.res", outputResourceDir,
  161. "hl2\\resource", "gamemenu.res", outputResourceDir,
  162. "hl2\\resource", "hl2_*.txt", outputResourceDir,
  163. "hl2\\resource", "serverevents.res", outputResourceDir,
  164. "hl2\\resource", "sourcescheme.res", outputResourceDir,
  165. };
  166. // Copy gameinfo.txt
  167. const char *replacements[] =
  168. {
  169. "%modname%", m_ModName
  170. };
  171. retVal = CopyWithReplacements("CreateModFiles\\hl2\\gameinfo_ep1.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  172. if ( retVal &&
  173. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  174. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  175. {
  176. retVal = true;
  177. }
  178. else
  179. {
  180. retVal = false;
  181. }
  182. return retVal;
  183. }
  184. bool CModWizardSubPanel_CopyFiles_Source2009::BuildCopyFilesForMod_HL2()
  185. {
  186. bool retVal = false;
  187. char outputSrcDirName[MAX_PATH];
  188. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  189. char outputUIDir[MAX_PATH], outputResourceDir[MAX_PATH], outputScriptsDir[MAX_PATH], outputCFGDir[MAX_PATH];
  190. Q_snprintf( outputUIDir, sizeof( outputUIDir ), "%sResource%cUI", m_OutModGamedirName, CORRECT_PATH_SEPARATOR );
  191. Q_snprintf( outputResourceDir, sizeof( outputResourceDir ), "%sresource", m_OutModGamedirName );
  192. Q_snprintf( outputScriptsDir, sizeof( outputScriptsDir ), "%sscripts", m_OutModGamedirName );
  193. Q_snprintf( outputCFGDir, sizeof( outputCFGDir ), "%scfg", m_OutModGamedirName );
  194. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  195. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  196. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  197. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  198. // These go in c:\mymod
  199. char *sources_mappings[] =
  200. {
  201. "src_mod\\source2009", "*.*", outputSrcDirName
  202. };
  203. char outputGamedirNameNoSlash[MAX_PATH];
  204. Q_strncpy( outputGamedirNameNoSlash, m_OutModGamedirName, sizeof( outputGamedirNameNoSlash ) );
  205. if ( strlen( outputGamedirNameNoSlash ) > 0 )
  206. outputGamedirNameNoSlash[strlen(outputGamedirNameNoSlash)-1] = 0;
  207. // These go in c:\steam\steamapps\sourcemods\modname
  208. char *content_mappings[] =
  209. {
  210. "game_content\\half-life 2\\hl2","lights.rad", outputGamedirNameNoSlash,
  211. "game_content\\half-life 2\\hl2","detail.vbsp", outputGamedirNameNoSlash,
  212. "CreateModFiles\\source2009\\singleplayer\\scripts", "*.*", outputScriptsDir,
  213. "CreateModFiles\\source2009\\singleplayer\\cfg", "*.*", outputCFGDir,
  214. "CreateModFiles\\source2009\\singleplayer\\resource", "clientscheme.res", outputResourceDir,
  215. "CreateModFiles\\source2009\\singleplayer\\resource", "HL2EP2.ttf", outputResourceDir,
  216. };
  217. // Copy gameinfo.txt
  218. const char *replacements[] =
  219. {
  220. "%modname%", m_ModName
  221. };
  222. retVal = CopyWithReplacements("CreateModFiles\\source2009\\gameinfo_sp.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  223. if ( retVal &&
  224. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  225. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  226. {
  227. retVal = true;
  228. }
  229. else
  230. {
  231. retVal = false;
  232. }
  233. return retVal;
  234. }
  235. bool CModWizardSubPanel_CopyFiles_Source2007::BuildCopyFilesForMod_HL2()
  236. {
  237. bool retVal = false;
  238. char outputSrcDirName[MAX_PATH];
  239. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  240. char outputUIDir[MAX_PATH], outputResourceDir[MAX_PATH], outputScriptsDir[MAX_PATH], outputCFGDir[MAX_PATH];
  241. Q_snprintf( outputUIDir, sizeof( outputUIDir ), "%sResource%cUI", m_OutModGamedirName, CORRECT_PATH_SEPARATOR );
  242. Q_snprintf( outputResourceDir, sizeof( outputResourceDir ), "%sresource", m_OutModGamedirName );
  243. Q_snprintf( outputScriptsDir, sizeof( outputScriptsDir ), "%sscripts", m_OutModGamedirName );
  244. Q_snprintf( outputCFGDir, sizeof( outputCFGDir ), "%scfg", m_OutModGamedirName );
  245. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  246. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  247. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  248. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  249. // These go in c:\mymod
  250. char *sources_mappings[] =
  251. {
  252. "src_mod\\orangebox", "*.*", outputSrcDirName
  253. };
  254. char outputGamedirNameNoSlash[MAX_PATH];
  255. Q_strncpy( outputGamedirNameNoSlash, m_OutModGamedirName, sizeof( outputGamedirNameNoSlash ) );
  256. if ( strlen( outputGamedirNameNoSlash ) > 0 )
  257. outputGamedirNameNoSlash[strlen(outputGamedirNameNoSlash)-1] = 0;
  258. // These go in c:\steam\steamapps\sourcemods\modname
  259. char *content_mappings[] =
  260. {
  261. "game_content\\half-life 2\\hl2","lights.rad", outputGamedirNameNoSlash,
  262. "game_content\\half-life 2\\hl2","detail.vbsp", outputGamedirNameNoSlash,
  263. "CreateModFiles\\orangebox\\singleplayer\\scripts", "*.*", outputScriptsDir,
  264. "CreateModFiles\\orangebox\\singleplayer\\cfg", "*.*", outputCFGDir,
  265. "CreateModFiles\\orangebox\\singleplayer\\resource", "clientscheme.res", outputResourceDir,
  266. "CreateModFiles\\orangebox\\singleplayer\\resource", "HL2EP2.ttf", outputResourceDir,
  267. };
  268. // Copy gameinfo.txt
  269. const char *replacements[] =
  270. {
  271. "%modname%", m_ModName
  272. };
  273. retVal = CopyWithReplacements("CreateModFiles\\orangebox\\gameinfo_sp.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  274. if ( retVal &&
  275. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  276. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  277. {
  278. retVal = true;
  279. }
  280. else
  281. {
  282. retVal = false;
  283. }
  284. return retVal;
  285. }
  286. bool CModWizardSubPanel_CopyFiles_Source2006::BuildCopyFilesForMod_FromScratch()
  287. {
  288. bool retVal = false;
  289. char outputSrcDirName[MAX_PATH];
  290. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  291. // These go into c:\mymod
  292. char *sources_mappings[] =
  293. {
  294. "src_mod\\ep1", "*.*", outputSrcDirName,
  295. "sampleapp_sources", "*.*", m_OutputDirName
  296. };
  297. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  298. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  299. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  300. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  301. char *content_mappings[] =
  302. {
  303. "sampleapp", "*.*", m_OutModGamedirName,
  304. };
  305. // Copy gameinfo.txt
  306. const char *replacements[] =
  307. {
  308. "%modname%", m_ModName
  309. };
  310. retVal = CopyWithReplacements( "CreateModFiles\\base\\gameinfo_ep1.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  311. if ( retVal &&
  312. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  313. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  314. {
  315. retVal = true;
  316. }
  317. else
  318. {
  319. retVal = false;
  320. }
  321. return retVal;
  322. }
  323. bool CModWizardSubPanel_CopyFiles_Source2009::BuildCopyFilesForMod_FromScratch()
  324. {
  325. bool retVal = false;
  326. char outputSrcDirName[MAX_PATH];
  327. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  328. // These go into c:\mymod
  329. char *sources_mappings[] =
  330. {
  331. "src_mod\\source2009", "*.*", outputSrcDirName,
  332. "sampleapp_sources", "*.*", m_OutputDirName
  333. };
  334. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  335. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  336. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  337. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  338. char *content_mappings[] =
  339. {
  340. "CreateModFiles\\source2009\\template", "*.*", m_OutModGamedirName,
  341. };
  342. // Copy gameinfo.txt
  343. const char *replacements[] =
  344. {
  345. "%modname%", m_ModName
  346. };
  347. retVal = CopyWithReplacements( "CreateModFiles\\source2009\\gameinfo_template.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  348. if ( retVal &&
  349. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  350. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  351. {
  352. retVal = true;
  353. }
  354. else
  355. {
  356. retVal = false;
  357. }
  358. return retVal;
  359. }
  360. bool CModWizardSubPanel_CopyFiles_Source2007::BuildCopyFilesForMod_FromScratch()
  361. {
  362. bool retVal = false;
  363. char outputSrcDirName[MAX_PATH];
  364. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  365. // These go into c:\mymod
  366. char *sources_mappings[] =
  367. {
  368. "src_mod\\orangebox", "*.*", outputSrcDirName,
  369. "sampleapp_sources", "*.*", m_OutputDirName
  370. };
  371. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  372. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  373. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  374. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  375. char *content_mappings[] =
  376. {
  377. "CreateModFiles\\orangebox\\template", "*.*", m_OutModGamedirName,
  378. };
  379. // Copy gameinfo.txt
  380. const char *replacements[] =
  381. {
  382. "%modname%", m_ModName
  383. };
  384. retVal = CopyWithReplacements( "CreateModFiles\\orangebox\\gameinfo_template.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  385. if ( retVal &&
  386. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  387. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  388. {
  389. retVal = true;
  390. }
  391. else
  392. {
  393. retVal = false;
  394. }
  395. return retVal;
  396. }
  397. bool CModWizardSubPanel_CopyFiles_Source2006::BuildCopyFilesForMod_HL2MP()
  398. {
  399. bool retVal = false;
  400. char outputSrcDirName[MAX_PATH];
  401. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  402. char outputUIDir[MAX_PATH], outputResourceDir[MAX_PATH], outputScriptsDir[MAX_PATH];
  403. Q_snprintf( outputUIDir, sizeof( outputUIDir ), "%sResource%cUI", m_OutModGamedirName, CORRECT_PATH_SEPARATOR );
  404. Q_snprintf( outputResourceDir, sizeof( outputResourceDir ), "%sresource", m_OutModGamedirName );
  405. Q_snprintf( outputScriptsDir, sizeof( outputScriptsDir ), "%sscripts", m_OutModGamedirName );
  406. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  407. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  408. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  409. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  410. // These go in c:\mymod
  411. char *sources_mappings[] =
  412. {
  413. "src_mod\\ep1", "*.*", outputSrcDirName
  414. };
  415. char outputGamedirNameNoSlash[MAX_PATH];
  416. Q_strncpy( outputGamedirNameNoSlash, m_OutModGamedirName, sizeof( outputGamedirNameNoSlash ) );
  417. if ( strlen( outputGamedirNameNoSlash ) > 0 )
  418. outputGamedirNameNoSlash[strlen(outputGamedirNameNoSlash)-1] = 0;
  419. // These go in c:\steam\steamapps\sourcemods\modname
  420. char *content_mappings[] =
  421. {
  422. "game_content\\half-life 2 deathmatch\\hl2mp", "lights.rad", outputGamedirNameNoSlash,
  423. "game_content\\half-life 2 deathmatch\\hl2mp", "detail.vbsp", outputGamedirNameNoSlash,
  424. "CreateModFiles\\hl2mp\\scripts", "*.*", outputScriptsDir,
  425. "CreateModFiles\\hl2mp\\resource", "*.*", outputResourceDir,
  426. "CreateModFiles\\hl2mp\\resource\\ui", "*.*", outputUIDir
  427. };
  428. // Copy gameinfo.txt
  429. const char *replacements[] =
  430. {
  431. "%modname%", m_ModName
  432. };
  433. retVal = CopyWithReplacements( "CreateModFiles\\hl2mp\\gameinfo_ep1.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  434. if ( retVal &&
  435. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  436. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  437. {
  438. retVal = true;
  439. }
  440. else
  441. {
  442. retVal = false;
  443. }
  444. return retVal;
  445. }
  446. bool CModWizardSubPanel_CopyFiles_Source2009::BuildCopyFilesForMod_HL2MP()
  447. {
  448. bool retVal = false;
  449. char outputSrcDirName[MAX_PATH];
  450. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  451. char outputUIDir[MAX_PATH], outputResourceDir[MAX_PATH], outputScriptsDir[MAX_PATH];
  452. Q_snprintf( outputUIDir, sizeof( outputUIDir ), "%sResource%cUI", m_OutModGamedirName, CORRECT_PATH_SEPARATOR );
  453. Q_snprintf( outputResourceDir, sizeof( outputResourceDir ), "%sresource", m_OutModGamedirName );
  454. Q_snprintf( outputScriptsDir, sizeof( outputScriptsDir ), "%sscripts", m_OutModGamedirName );
  455. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  456. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  457. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  458. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  459. // These go in c:\mymod
  460. char *sources_mappings[] =
  461. {
  462. "src_mod\\source2009", "*.*", outputSrcDirName
  463. };
  464. char outputGamedirNameNoSlash[MAX_PATH];
  465. Q_strncpy( outputGamedirNameNoSlash, m_OutModGamedirName, sizeof( outputGamedirNameNoSlash ) );
  466. if ( strlen( outputGamedirNameNoSlash ) > 0 )
  467. outputGamedirNameNoSlash[strlen(outputGamedirNameNoSlash)-1] = 0;
  468. // These go in c:\steam\steamapps\sourcemods\modname
  469. char *content_mappings[] =
  470. {
  471. "game_content\\half-life 2 deathmatch\\hl2mp", "lights.rad", outputGamedirNameNoSlash,
  472. "game_content\\half-life 2 deathmatch\\hl2mp", "detail.vbsp", outputGamedirNameNoSlash,
  473. "CreateModFiles\\source2009\\multiplayer", "*.*", m_OutModGamedirName,
  474. };
  475. // Copy gameinfo.txt
  476. const char *replacements[] =
  477. {
  478. "%modname%", m_ModName
  479. };
  480. retVal = CopyWithReplacements( "CreateModFiles\\source2009\\gameinfo_mp.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  481. if ( retVal &&
  482. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  483. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  484. {
  485. retVal = true;
  486. }
  487. else
  488. {
  489. retVal = false;
  490. }
  491. return retVal;
  492. }
  493. bool CModWizardSubPanel_CopyFiles_Source2007::BuildCopyFilesForMod_HL2MP()
  494. {
  495. bool retVal = false;
  496. char outputSrcDirName[MAX_PATH];
  497. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s%s", m_OutputDirName, "src" );
  498. char outputUIDir[MAX_PATH], outputResourceDir[MAX_PATH], outputScriptsDir[MAX_PATH];
  499. Q_snprintf( outputUIDir, sizeof( outputUIDir ), "%sResource%cUI", m_OutModGamedirName, CORRECT_PATH_SEPARATOR );
  500. Q_snprintf( outputResourceDir, sizeof( outputResourceDir ), "%sresource", m_OutModGamedirName );
  501. Q_snprintf( outputScriptsDir, sizeof( outputScriptsDir ), "%sscripts", m_OutModGamedirName );
  502. // Also, create the mapsrc/modelsrc/materialsrc directories now because they may not be there yet.
  503. CreateSubdirectory( m_OutputDirName, "modelsrc" );
  504. CreateSubdirectory( m_OutputDirName, "materialsrc" );
  505. CreateSubdirectory( m_OutputDirName, "mapsrc" );
  506. // These go in c:\mymod
  507. char *sources_mappings[] =
  508. {
  509. "src_mod\\orangebox", "*.*", outputSrcDirName
  510. };
  511. char outputGamedirNameNoSlash[MAX_PATH];
  512. Q_strncpy( outputGamedirNameNoSlash, m_OutModGamedirName, sizeof( outputGamedirNameNoSlash ) );
  513. if ( strlen( outputGamedirNameNoSlash ) > 0 )
  514. outputGamedirNameNoSlash[strlen(outputGamedirNameNoSlash)-1] = 0;
  515. // These go in c:\steam\steamapps\sourcemods\modname
  516. char *content_mappings[] =
  517. {
  518. "game_content\\half-life 2 deathmatch\\hl2mp", "lights.rad", outputGamedirNameNoSlash,
  519. "game_content\\half-life 2 deathmatch\\hl2mp", "detail.vbsp", outputGamedirNameNoSlash,
  520. "CreateModFiles\\orangebox\\multiplayer", "*.*", m_OutModGamedirName,
  521. };
  522. // Copy gameinfo.txt
  523. const char *replacements[] =
  524. {
  525. "%modname%", m_ModName
  526. };
  527. retVal = CopyWithReplacements( "CreateModFiles\\orangebox\\gameinfo_mp.txt", replacements, ARRAYSIZE( replacements ), "%s%s", m_OutModGamedirName, "gameinfo.txt" );
  528. if ( retVal &&
  529. BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) ) &&
  530. BuildCopyFilesForMappings( content_mappings, ARRAYSIZE( content_mappings ) ) )
  531. {
  532. retVal = true;
  533. }
  534. else
  535. {
  536. retVal = false;
  537. }
  538. return retVal;
  539. }
  540. bool CModWizardSubPanel_CopyFiles_Source2006::BuildCopyFilesForMod_SourceCodeOnly()
  541. {
  542. char outputSrcDirName[MAX_PATH];
  543. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s", m_OutputDirName );
  544. int len = strlen( outputSrcDirName );
  545. if ( len > 0 && PATHSEPARATOR( outputSrcDirName[len-1] ) )
  546. outputSrcDirName[len-1] = 0;
  547. char *sources_mappings[] =
  548. {
  549. "src_mod\\ep1", "*.*", outputSrcDirName
  550. };
  551. return BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) );
  552. }
  553. bool CModWizardSubPanel_CopyFiles_Source2009::BuildCopyFilesForMod_SourceCodeOnly()
  554. {
  555. char outputSrcDirName[MAX_PATH];
  556. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s", m_OutputDirName );
  557. int len = strlen( outputSrcDirName );
  558. if ( len > 0 && PATHSEPARATOR( outputSrcDirName[len-1] ) )
  559. outputSrcDirName[len-1] = 0;
  560. char *sources_mappings[] =
  561. {
  562. "src_mod\\source2009", "*.*", outputSrcDirName
  563. };
  564. return BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) );
  565. }
  566. bool CModWizardSubPanel_CopyFiles_Source2007::BuildCopyFilesForMod_SourceCodeOnly()
  567. {
  568. char outputSrcDirName[MAX_PATH];
  569. Q_snprintf( outputSrcDirName, sizeof( outputSrcDirName ), "%s", m_OutputDirName );
  570. int len = strlen( outputSrcDirName );
  571. if ( len > 0 && PATHSEPARATOR( outputSrcDirName[len-1] ) )
  572. outputSrcDirName[len-1] = 0;
  573. char *sources_mappings[] =
  574. {
  575. "src_mod\\orangebox", "*.*", outputSrcDirName
  576. };
  577. return BuildCopyFilesForMappings( sources_mappings, ARRAYSIZE( sources_mappings ) );
  578. }
  579. void CModWizardSubPanel_CopyFiles::OnTick()
  580. {
  581. if ( m_iCurCopyFile == -1 )
  582. {
  583. // Figure out if we're an hl2 mod or not.
  584. m_ModType = ModType_HL2;
  585. CModWizardSubPanel_Intro *pIntro = dynamic_cast<CModWizardSubPanel_Intro*>(GetWizardPanel()->FindChildByName("CModWizardSubPanel_Intro"));
  586. if ( pIntro )
  587. m_ModType = pIntro->GetModType();
  588. if ( m_ModType == ModType_HL2 )
  589. {
  590. if ( !BuildCopyFilesForMod_HL2() )
  591. return;
  592. }
  593. else if ( m_ModType == ModType_HL2_Multiplayer )
  594. {
  595. if ( !BuildCopyFilesForMod_HL2MP() )
  596. return;
  597. }
  598. else if ( m_ModType == ModType_SourceCodeOnly )
  599. {
  600. if ( !BuildCopyFilesForMod_SourceCodeOnly() )
  601. return;
  602. }
  603. else
  604. {
  605. if ( !BuildCopyFilesForMod_FromScratch() )
  606. return;
  607. }
  608. // Prepare the lists of files to copy.
  609. m_iCurCopyFile = 0;
  610. // Get the output dir name sans the slash at the end.
  611. if ( m_ModType != ModType_SourceCodeOnly )
  612. {
  613. char outModGamedirNameNoSlash[MAX_PATH];
  614. Assert( m_OutModGamedirName[strlen(m_OutModGamedirName)-1] == CORRECT_PATH_SEPARATOR );
  615. Q_StrSlice( m_OutModGamedirName, 0, -1, outModGamedirNameNoSlash, sizeof( outModGamedirNameNoSlash ) );
  616. // Figure out the steam directory. Starting with gamedir, which is
  617. //
  618. char steamdir[MAX_PATH];
  619. Q_strncpy( steamdir, gamedir, sizeof( steamdir ) ); // c:\valve\steam\steamapps\name\sourcesdk\launcher
  620. Q_StripLastDir( steamdir, sizeof( steamdir ) ); // c:\valve\steam\steamapps\name\sourcesdk
  621. Q_StripLastDir( steamdir, sizeof( steamdir ) ); // c:\valve\steam\steamapps\name
  622. Q_StripLastDir( steamdir, sizeof( steamdir ) ); // c:\valve\steam\steamapps
  623. Q_StripLastDir( steamdir, sizeof( steamdir ) ); // c:\valve\steam
  624. Q_AppendSlash( steamdir, sizeof( steamdir ) );
  625. // Setup the path to their hl2 game folder.
  626. char hl2dir[MAX_PATH];
  627. Q_strncpy( hl2dir, gamedir, sizeof( hl2dir ) ); // c:\valve\steam\steamapps\name\sourcesdk\launcher
  628. Q_StripLastDir( hl2dir, sizeof( hl2dir ) ); // c:\valve\steam\steamapps\name\sourcesdk
  629. Q_StripLastDir( hl2dir, sizeof( hl2dir ) ); // c:\valve\steam\steamapps\name
  630. Q_AppendSlash( hl2dir, sizeof( hl2dir ) );
  631. V_strncat( hl2dir, "source sdk base", sizeof( hl2dir ), COPY_ALL_CHARACTERS );
  632. // If the engine version is 'orange box' then use the new 'source sdk base 2009' to launch the mods
  633. if ( !V_strcmp( g_engineDir, "orangebox" ) )
  634. {
  635. V_strncat( hl2dir, " 2009", sizeof( hl2dir ), COPY_ALL_CHARACTERS );
  636. }
  637. // If the engine version isn't 'source2007' then use the new 'source sdk base 2007' to launch the mods
  638. else if ( !V_strcmp( g_engineDir, "source2007" ) )
  639. {
  640. V_strncat( hl2dir, " 2007", sizeof( hl2dir ), COPY_ALL_CHARACTERS );
  641. }
  642. char szAppID[10];
  643. // DoD only people need to run their mod via DoD
  644. if ( IsGameSubscribed( GetAppSteamAppId( k_App_DODS ) ) && !IsGameSubscribed( GetAppSteamAppId( k_App_HL2 ) ) && !IsGameSubscribed( GetAppSteamAppId( k_App_HL2MP ) ) )
  645. {
  646. _itoa_s(GetAppSteamAppId( k_App_DODS ), szAppID, sizeof(szAppID), 10);
  647. }
  648. else
  649. {
  650. // Otherwise use Source SDK Base
  651. _itoa_s(GetAppSteamAppId( k_App_SDK_BASE ), szAppID, sizeof(szAppID), 10);
  652. }
  653. // Copy the batch files.
  654. const char *replacements[] =
  655. {
  656. "%steamdir%", steamdir,
  657. "%appid%", szAppID,
  658. "%hl2dir%", hl2dir,
  659. "%moddir%", outModGamedirNameNoSlash,
  660. "%bindir%", GetSDKToolsBinDirectory()
  661. };
  662. const char *filenames[] =
  663. {
  664. "run_mod.bat",
  665. "run_hlmv.bat",
  666. "run_studiomdl.bat",
  667. "run_hammer.bat"
  668. };
  669. for ( int iFilename=0; iFilename < ARRAYSIZE( filenames ); iFilename++ )
  670. {
  671. char srcFilename[MAX_PATH];
  672. Q_snprintf( srcFilename, sizeof( srcFilename ), "CreateModFiles\\%s", filenames[iFilename] );
  673. if ( !CopyWithReplacements(
  674. srcFilename, replacements, ARRAYSIZE( replacements ),
  675. "%s%s", m_OutputDirName, filenames[iFilename] ) )
  676. {
  677. vgui::ivgui()->RemoveTickSignal( GetVPanel() );
  678. GetWizardPanel()->SetCancelButtonEnabled( true );
  679. return;
  680. }
  681. }
  682. }
  683. }
  684. else
  685. {
  686. bool bFinished = false;
  687. // File copying has begun. Copy N more files and update our label.
  688. int nCopied = 0;
  689. while ( nCopied < 10 )
  690. {
  691. if ( m_iCurCopyFile >= m_FileCopyInfos.Count() )
  692. {
  693. // Also, add a game configuration.
  694. char modGamedirNoSlash[MAX_PATH];
  695. Q_strncpy( modGamedirNoSlash, m_OutModGamedirName, sizeof( modGamedirNoSlash ) );
  696. if ( strlen( modGamedirNoSlash ) > 0 )
  697. {
  698. if ( modGamedirNoSlash[strlen(modGamedirNoSlash)-1] == '/' || modGamedirNoSlash[strlen(modGamedirNoSlash)-1] == '\\' )
  699. modGamedirNoSlash[strlen(modGamedirNoSlash)-1] = 0;
  700. }
  701. if ( m_ModType != ModType_SourceCodeOnly )
  702. AddConfig( m_ModName, modGamedirNoSlash, m_ModType );
  703. // Setup the next panel.
  704. CModWizardSubPanel_Finished *pNextPanel = dynamic_cast<CModWizardSubPanel_Finished*>(GetWizardPanel()->FindChildByName("CModWizardSubPanel_Finished"));
  705. if ( !pNextPanel )
  706. {
  707. VGUIMessageBox( this, "Error", "Can't find CModWizardSubPanel_Finished panel." );
  708. GetWizardPanel()->SetCancelButtonEnabled( true );
  709. return;
  710. }
  711. pNextPanel->GetReady( m_OutputDirName );
  712. // Direct them out..
  713. GetWizardPanel()->SetNextButtonEnabled( true );
  714. m_pFinishedLabel->SetVisible( true );
  715. m_pProgressBar->SetProgress( 1 );
  716. bFinished = true;
  717. vgui::ivgui()->RemoveTickSignal( GetVPanel() );
  718. break;
  719. }
  720. // Copy another file.
  721. bool bRet= false;
  722. CFileCopyInfo *pInfo = &m_FileCopyInfos[m_iCurCopyFile++];
  723. if ( !HandleSpecialFileCopy( pInfo, bRet ) )
  724. {
  725. bRet = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  726. }
  727. if ( !bRet )
  728. {
  729. vgui::ivgui()->RemoveTickSignal( GetVPanel() );
  730. GetWizardPanel()->SetCancelButtonEnabled( true );
  731. break;
  732. }
  733. ++nCopied;
  734. }
  735. // Update our label.
  736. if ( !bFinished )
  737. {
  738. unsigned int iNum = min( m_iCurCopyFile, m_FileCopyInfos.Count()-1 );
  739. if ( iNum < (unsigned int)m_FileCopyInfos.Count() )
  740. {
  741. char msg[512];
  742. Q_snprintf( msg, sizeof( msg ), "%s", m_FileCopyInfos[iNum].m_InFilename );
  743. m_pLabel->SetText( msg );
  744. m_pProgressBar->SetProgress( (float)iNum / m_FileCopyInfos.Count() );
  745. }
  746. }
  747. }
  748. BaseClass::OnTick();
  749. }
  750. bool IsVCProjFile( const char *pFilename )
  751. {
  752. char ext[512];
  753. Q_StrRight( pFilename, 7, ext, sizeof( ext ) );
  754. return ( Q_stricmp( ext, ".vcproj" ) == 0 );
  755. }
  756. bool CModWizardSubPanel_CopyFiles_Source2009::HandleReplacements_GameProjectFiles( CFileCopyInfo *pInfo, bool &bErrorStatus )
  757. {
  758. // Speed up the copy process a bit, if it's not a vcproj, get out.
  759. if ( !IsVCProjFile( pInfo->m_InFilename ) )
  760. return false;
  761. char replaceWith[MAX_PATH] = {0};
  762. const char *replacements[] =
  763. {
  764. "..\\..\\game\\template\\", replaceWith,
  765. "..\\..\\game\\sdksample\\", replaceWith,
  766. "..\\..\\game\\hl2\\", replaceWith,
  767. "..\\..\\game\\hl2mp\\", replaceWith,
  768. "..\\game\\bin", "..\\bin"
  769. };
  770. // No 'dx8' shaders in orange box, at least any time soon, just keeping it cleaned up.
  771. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\materialsystem\\stdshaders\\stdshader_dx9-2005.vcproj" ) == 0 )
  772. {
  773. bErrorStatus = true;
  774. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  775. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  776. return true;
  777. }
  778. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game\\client\\client_scratch-2005.vcproj" ) == 0 ||
  779. Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game\\server\\server_scratch-2005.vcproj" ) == 0 )
  780. {
  781. bErrorStatus = true;
  782. if ( m_ModType == ModType_FromScratch )
  783. {
  784. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  785. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  786. }
  787. return true;
  788. }
  789. // removed 'hl2' projects as they're not needed in orange box anymore.
  790. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game\\client\\client_episodic-2005.vcproj" ) == 0 ||
  791. Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game\\server\\server_episodic-2005.vcproj" ) == 0 )
  792. {
  793. bErrorStatus = true;
  794. if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly )
  795. {
  796. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  797. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  798. }
  799. return true;
  800. }
  801. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game\\client\\client_hl2mp-2005.vcproj" ) == 0 ||
  802. Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game\\server\\server_hl2mp-2005.vcproj" ) == 0 )
  803. {
  804. bErrorStatus = true;
  805. if ( m_ModType == ModType_HL2_Multiplayer )
  806. {
  807. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  808. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  809. }
  810. return true;
  811. }
  812. return false;
  813. }
  814. bool CModWizardSubPanel_CopyFiles_Source2007::HandleReplacements_GameProjectFiles( CFileCopyInfo *pInfo, bool &bErrorStatus )
  815. {
  816. // Speed up the copy process a bit, if it's not a vcproj, get out.
  817. if ( !IsVCProjFile( pInfo->m_InFilename ) )
  818. return false;
  819. char replaceWith[MAX_PATH] = {0};
  820. const char *replacements[] =
  821. {
  822. "..\\..\\game\\template\\", replaceWith,
  823. "..\\..\\game\\sdksample\\", replaceWith,
  824. "..\\..\\game\\hl2\\", replaceWith,
  825. "..\\..\\game\\hl2mp\\", replaceWith,
  826. "..\\game\\bin", "..\\bin"
  827. };
  828. // No 'dx8' shaders in orange box, at least any time soon, just keeping it cleaned up.
  829. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\materialsystem\\stdshaders\\stdshader_dx9-2005.vcproj" ) == 0 )
  830. {
  831. bErrorStatus = true;
  832. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  833. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  834. return true;
  835. }
  836. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game\\client\\client_scratch-2005.vcproj" ) == 0 ||
  837. Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game\\server\\server_scratch-2005.vcproj" ) == 0 )
  838. {
  839. bErrorStatus = true;
  840. if ( m_ModType == ModType_FromScratch )
  841. {
  842. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  843. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  844. }
  845. return true;
  846. }
  847. // removed 'hl2' projects as they're not needed in orange box anymore.
  848. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game\\client\\client_episodic-2005.vcproj" ) == 0 ||
  849. Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game\\server\\server_episodic-2005.vcproj" ) == 0 )
  850. {
  851. bErrorStatus = true;
  852. if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly )
  853. {
  854. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  855. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  856. }
  857. return true;
  858. }
  859. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game\\client\\client_hl2mp-2005.vcproj" ) == 0 ||
  860. Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game\\server\\server_hl2mp-2005.vcproj" ) == 0 )
  861. {
  862. bErrorStatus = true;
  863. if ( m_ModType == ModType_HL2_Multiplayer )
  864. {
  865. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  866. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  867. }
  868. return true;
  869. }
  870. return false;
  871. }
  872. bool CModWizardSubPanel_CopyFiles_Source2006::HandleReplacements_GameProjectFiles( CFileCopyInfo *pInfo, bool &bErrorStatus )
  873. {
  874. // Speed up the copy process a bit, if it's not a vcproj, get out.
  875. if ( !IsVCProjFile( pInfo->m_InFilename ) )
  876. return false;
  877. char replaceWith[MAX_PATH] = {0};
  878. const char *replacements[] =
  879. {
  880. "..\\..\\game\\sdksample\\", replaceWith,
  881. "..\\..\\game\\hl2\\", replaceWith,
  882. "..\\..\\game\\hl2mp\\", replaceWith,
  883. "..\\game\\bin", "..\\bin"
  884. };
  885. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\materialsystem\\stdshaders\\stdshader_dx8-2003.vcproj" ) == 0 ||
  886. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\materialsystem\\stdshaders\\stdshader_dx8-2005.vcproj" ) == 0 ||
  887. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\materialsystem\\stdshaders\\stdshader_dx9-2003.vcproj" ) == 0 ||
  888. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\materialsystem\\stdshaders\\stdshader_dx9-2005.vcproj" ) == 0 )
  889. {
  890. bErrorStatus = true;
  891. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  892. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  893. return true;
  894. }
  895. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\cl_dll\\client_scratch-2003.vcproj" ) == 0 ||
  896. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\cl_dll\\client_scratch-2005.vcproj" ) == 0 ||
  897. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\dlls\\server_scratch-2003.vcproj" ) == 0 ||
  898. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\dlls\\server_scratch-2005.vcproj" ) == 0 )
  899. {
  900. bErrorStatus = true;
  901. if ( m_ModType == ModType_FromScratch )
  902. {
  903. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  904. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  905. }
  906. return true;
  907. }
  908. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\cl_dll\\client_hl2-2003.vcproj" ) == 0 ||
  909. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\cl_dll\\client_hl2-2005.vcproj" ) == 0 ||
  910. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\dlls\\server_hl2-2003.vcproj" ) == 0 ||
  911. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\dlls\\server_hl2-2005.vcproj" ) == 0 )
  912. {
  913. bErrorStatus = true;
  914. if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly )
  915. {
  916. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  917. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  918. }
  919. return true;
  920. }
  921. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\cl_dll\\client_hl2mp-2003.vcproj" ) == 0 ||
  922. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\cl_dll\\client_hl2mp-2005.vcproj" ) == 0 ||
  923. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\dlls\\server_hl2mp-2003.vcproj" ) == 0 ||
  924. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\dlls\\server_hl2mp-2005.vcproj" ) == 0 )
  925. {
  926. bErrorStatus = true;
  927. if ( m_ModType == ModType_HL2_Multiplayer )
  928. {
  929. Q_snprintf( replaceWith, sizeof( replaceWith ), "%s", m_OutModGamedirName );
  930. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  931. }
  932. return true;
  933. }
  934. return false;
  935. }
  936. bool CModWizardSubPanel_CopyFiles::HandleReplacements_GenericVCProj( CFileCopyInfo *pInfo, bool &bErrorStatus )
  937. {
  938. if ( IsVCProjFile( pInfo->m_InFilename ) )
  939. {
  940. // This code is for all the tools. Internally, Valve uses <base dir>\game\bin, and externally,
  941. // they're using <game dir>\bin to store tools.
  942. const char *vcprojReplacements[] =
  943. {
  944. "..\\game\\bin", "..\\bin"
  945. };
  946. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, vcprojReplacements, ARRAYSIZE( vcprojReplacements ), "%s", pInfo->m_OutFilename );
  947. return true;
  948. }
  949. return false;
  950. }
  951. bool CModWizardSubPanel_CopyFiles_Source2006::HandleReplacements_Solution( CFileCopyInfo *pInfo, bool &bErrorStatus )
  952. {
  953. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\game_scratch-2003.sln" ) == 0 ||
  954. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\game_scratch-2005.sln" ) == 0)
  955. {
  956. bErrorStatus = true;
  957. if ( m_ModType == ModType_FromScratch )
  958. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  959. return true;
  960. }
  961. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\game_hl2-2003.sln" ) == 0 ||
  962. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\game_hl2-2005.sln" ) == 0)
  963. {
  964. bErrorStatus = true;
  965. if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly )
  966. {
  967. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  968. }
  969. return true;
  970. }
  971. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\game_hl2mp-2003.sln" ) == 0 ||
  972. Q_stricmp( pInfo->m_InFilename, "src_mod\\ep1\\game_hl2mp-2005.sln" ) == 0)
  973. {
  974. bErrorStatus = true;
  975. if ( m_ModType == ModType_HL2_Multiplayer )
  976. {
  977. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  978. }
  979. return true;
  980. }
  981. return false;
  982. }
  983. bool CModWizardSubPanel_CopyFiles_Source2009::HandleReplacements_Solution( CFileCopyInfo *pInfo, bool &bErrorStatus )
  984. {
  985. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game_scratch-2005.sln" ) == 0)
  986. {
  987. bErrorStatus = true;
  988. if ( m_ModType == ModType_FromScratch )
  989. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  990. return true;
  991. }
  992. // Episodic now, not 'hl2'!!
  993. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game_episodic-2005.sln" ) == 0)
  994. {
  995. bErrorStatus = true;
  996. if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly )
  997. {
  998. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  999. }
  1000. return true;
  1001. }
  1002. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game_hl2mp-2005.sln" ) == 0)
  1003. {
  1004. bErrorStatus = true;
  1005. if ( m_ModType == ModType_HL2_Multiplayer )
  1006. {
  1007. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  1008. }
  1009. return true;
  1010. }
  1011. return false;
  1012. }
  1013. bool CModWizardSubPanel_CopyFiles_Source2007::HandleReplacements_Solution( CFileCopyInfo *pInfo, bool &bErrorStatus )
  1014. {
  1015. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game_scratch-2005.sln" ) == 0)
  1016. {
  1017. bErrorStatus = true;
  1018. if ( m_ModType == ModType_FromScratch )
  1019. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  1020. return true;
  1021. }
  1022. // Episodic now, not 'hl2'!!
  1023. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game_episodic-2005.sln" ) == 0)
  1024. {
  1025. bErrorStatus = true;
  1026. if ( m_ModType == ModType_HL2 || m_ModType == ModType_SourceCodeOnly )
  1027. {
  1028. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  1029. }
  1030. return true;
  1031. }
  1032. else if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game_hl2mp-2005.sln" ) == 0)
  1033. {
  1034. bErrorStatus = true;
  1035. if ( m_ModType == ModType_HL2_Multiplayer )
  1036. {
  1037. bErrorStatus = DoCopyFile( pInfo->m_InFilename, pInfo->m_OutFilename );
  1038. }
  1039. return true;
  1040. }
  1041. return false;
  1042. }
  1043. bool CModWizardSubPanel_CopyFiles_Source2009::HandleReplacements_TemplateOptions( CFileCopyInfo *pInfo, bool &bErrorStatus )
  1044. {
  1045. // Copy over the sdk_shareddefs.h with replacements for the defines.
  1046. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\source2009\\game\\shared\\sdk\\sdk_shareddefs.h" ) == 0 )
  1047. {
  1048. // If the panel can't be found, get out.
  1049. CModWizardSubPanel_TemplateOptions *pTemplate = dynamic_cast<CModWizardSubPanel_TemplateOptions*>(GetWizardPanel()->FindChildByName("CModWizardSubPanel_TemplateOptions"));
  1050. if ( !pTemplate )
  1051. return false;
  1052. const char *replacements[] =
  1053. {
  1054. "%TemplateOptionTeams%", pTemplate->GetOption(TPOPTION_TEAMS),
  1055. "%TemplateOptionClasses%", pTemplate->GetOption(TPOPTION_CLASSES),
  1056. "%TemplateOptionStamina%", pTemplate->GetOption(TPOPTION_STAMINA),
  1057. "%TemplateOptionSprinting%", pTemplate->GetOption(TPOPTION_SPRINTING),
  1058. "%TemplateOptionProne%", pTemplate->GetOption(TPOPTION_PRONE),
  1059. "%TemplateOptionShootWhileSprinting%", pTemplate->GetOption(TPOPTION_SHOOTSPRINTING),
  1060. "%TemplateOptionShootOnLadders%", pTemplate->GetOption(TPOPTION_SHOOTLADDERS),
  1061. "%TemplateOptionShootWhileJumping%", pTemplate->GetOption(TPOPTION_SHOOTJUMPING)
  1062. };
  1063. bErrorStatus = true;
  1064. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  1065. return true;
  1066. }
  1067. return false;
  1068. }
  1069. bool CModWizardSubPanel_CopyFiles_Source2007::HandleReplacements_TemplateOptions( CFileCopyInfo *pInfo, bool &bErrorStatus )
  1070. {
  1071. // Copy over the sdk_shareddefs.h with replacements for the defines.
  1072. if ( Q_stricmp( pInfo->m_InFilename, "src_mod\\orangebox\\game\\shared\\sdk\\sdk_shareddefs.h" ) == 0 )
  1073. {
  1074. // If the panel can't be found, get out.
  1075. CModWizardSubPanel_TemplateOptions *pTemplate = dynamic_cast<CModWizardSubPanel_TemplateOptions*>(GetWizardPanel()->FindChildByName("CModWizardSubPanel_TemplateOptions"));
  1076. if ( !pTemplate )
  1077. return false;
  1078. const char *replacements[] =
  1079. {
  1080. "%TemplateOptionTeams%", pTemplate->GetOption(TPOPTION_TEAMS),
  1081. "%TemplateOptionClasses%", pTemplate->GetOption(TPOPTION_CLASSES),
  1082. "%TemplateOptionStamina%", pTemplate->GetOption(TPOPTION_STAMINA),
  1083. "%TemplateOptionSprinting%", pTemplate->GetOption(TPOPTION_SPRINTING),
  1084. "%TemplateOptionProne%", pTemplate->GetOption(TPOPTION_PRONE),
  1085. "%TemplateOptionShootWhileSprinting%", pTemplate->GetOption(TPOPTION_SHOOTSPRINTING),
  1086. "%TemplateOptionShootOnLadders%", pTemplate->GetOption(TPOPTION_SHOOTLADDERS),
  1087. "%TemplateOptionShootWhileJumping%", pTemplate->GetOption(TPOPTION_SHOOTJUMPING)
  1088. };
  1089. bErrorStatus = true;
  1090. bErrorStatus = CopyWithReplacements( pInfo->m_InFilename, replacements, ARRAYSIZE( replacements ), "%s", pInfo->m_OutFilename );
  1091. return true;
  1092. }
  1093. return false;
  1094. }
  1095. bool CModWizardSubPanel_CopyFiles::HandleSpecialFileCopy( CFileCopyInfo *pInfo, bool &bErrorStatus )
  1096. {
  1097. if ( HandleReplacements_TemplateOptions( pInfo, bErrorStatus ) )
  1098. return true;
  1099. if ( HandleReplacements_GameProjectFiles( pInfo, bErrorStatus ) )
  1100. return true;
  1101. if ( HandleReplacements_GenericVCProj( pInfo, bErrorStatus ) )
  1102. return true;
  1103. if ( HandleReplacements_Solution( pInfo, bErrorStatus ) )
  1104. return true;
  1105. return false;
  1106. }
  1107. CModWizardSubPanel_CopyFiles_Source2006::CModWizardSubPanel_CopyFiles_Source2006( Panel *parent, const char *panelName ) : CModWizardSubPanel_CopyFiles( parent, panelName )
  1108. {
  1109. }
  1110. CModWizardSubPanel_CopyFiles_Source2007::CModWizardSubPanel_CopyFiles_Source2007( Panel *parent, const char *panelName ) : CModWizardSubPanel_CopyFiles( parent, panelName )
  1111. {
  1112. }
  1113. CModWizardSubPanel_CopyFiles_Source2009::CModWizardSubPanel_CopyFiles_Source2009( Panel *parent, const char *panelName ) : CModWizardSubPanel_CopyFiles( parent, panelName )
  1114. {
  1115. }