ConsoleHelpGen.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #if defined(WIN32) || defined(WIN64)
  9. #include "CrySystem_precompiled.h"
  10. #include "ConsoleHelpGen.h"
  11. #include "System.h"
  12. #include <AzCore/Utils/Utils.h>
  13. // remove bad characters, toupper, not very fast
  14. AZStd::string CConsoleHelpGen::FixAnchorName(const char* szName)
  15. {
  16. AZStd::string ret;
  17. const char* p = szName;
  18. while (*p)
  19. {
  20. if ((*p >= 'a' && *p <= 'z')
  21. || (*p >= 'A' && *p <= 'Z')
  22. || (*p >= '0' && *p <= '9'))
  23. {
  24. if (*p >= 'a' && *p <= 'z')
  25. {
  26. ret += *p - 'a' + 'A';
  27. }
  28. else
  29. {
  30. ret += *p;
  31. }
  32. }
  33. ++p;
  34. }
  35. return ret;
  36. }
  37. AZStd::string CConsoleHelpGen::GetCleanPrefix(const char* p)
  38. {
  39. AZStd::string sRet;
  40. while (*p != '_' && *p != 0)
  41. {
  42. sRet += *p++;
  43. }
  44. return sRet;
  45. }
  46. AZStd::string CConsoleHelpGen::SplitPrefixString_Part1(const char* p)
  47. {
  48. AZStd::string sRet;
  49. while (*p != 10 && *p != 13 && *p != 0)
  50. {
  51. sRet += *p++;
  52. }
  53. return sRet;
  54. }
  55. const char* CConsoleHelpGen::SplitPrefixString_Part2(const char* p)
  56. {
  57. while (*p != 10 && *p != 13 && *p != 0)
  58. {
  59. p++;
  60. }
  61. while (*p == 10 || *p == 13)
  62. {
  63. p++;
  64. }
  65. return p;
  66. }
  67. void CConsoleHelpGen::StartPage(FILE* f, const char* szPageName, const char* szPageDescription) const
  68. {
  69. if (m_eWorkMode == eWM_HTML)
  70. {
  71. fprintf(f, "<HTML><HEAD><TITLE>%s</TITLE><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">", szPageName);
  72. fprintf(f, "<META NAME=\"DESCRIPTION\" CONTENT=\"%s\">", szPageDescription);
  73. fprintf(f, "<META NAME=\"author\" content=\"Contributors to the Open 3D Engine Project\">");
  74. fprintf(f, "<META NAME=\"copyright\" CONTENT=\"Contributors to the Open 3D Engine Project\">");
  75. fprintf(f, "<META NAME=\"KEYWORDS\" CONTENT=\"O3DE\">");
  76. fprintf(f, "<META NAME=\"distribution\" CONTENT=\"Contributors to the Open 3D Engine Project\">");
  77. fprintf(f, "<META NAME=\"revisit-after\" CONTENT=\"10 days\">");
  78. fprintf(f, "<META NAME=\"robots\" CONTENT=\"INDEX, NOFOLLOW\">");
  79. fprintf(f, "</HEAD><BODY bgcolor=#ffffff leftmargin=0 topmargin=0 alink=#0000ff link=#0000ff vlink=#0000ff text=#000000>");
  80. }
  81. }
  82. void CConsoleHelpGen::EndPage(FILE* f) const
  83. {
  84. if (m_eWorkMode == eWM_HTML)
  85. {
  86. fprintf(f, "<P></P></BODY></HTML>");
  87. }
  88. }
  89. void CConsoleHelpGen::KeyValue(FILE* f, const char* szKey, const char* szValue) const
  90. {
  91. if (m_eWorkMode == eWM_HTML)
  92. {
  93. fprintf(f, "<b>%s:</b> %s<br>\n", szKey, szValue);
  94. }
  95. else if (m_eWorkMode == eWM_Confluence)
  96. {
  97. // fprintf(f,"*%s:* %s\n",szKey,szValue);
  98. fprintf(f, "| *%s:* | %s |\n", szKey, szValue);
  99. }
  100. else
  101. {
  102. assert(0);
  103. }
  104. }
  105. void CConsoleHelpGen::LogVersion(FILE* f) const
  106. {
  107. char s[1024];
  108. {
  109. AZ::Utils::GetExecutablePath(s, 1024);
  110. char fdir[_MAX_PATH];
  111. char fdrive[_MAX_PATH];
  112. char file[_MAX_PATH];
  113. char fext[_MAX_PATH];
  114. _splitpath_s(s, fdrive, fdir, file, fext);
  115. KeyValue(f, "Executable", (AZStd::string(file) + fext).c_str());
  116. }
  117. {
  118. time_t ltime;
  119. time(&ltime);
  120. tm today;
  121. localtime_s(&today, &ltime);
  122. strftime(s, 128, "%c", &today);
  123. KeyValue(f, "Date(MM/DD/YY) Time", s);
  124. }
  125. {
  126. const SFileVersion& ver = gEnv->pSystem->GetFileVersion();
  127. ver.ToString(s, sizeof(s));
  128. KeyValue(f, "FileVersion", s);
  129. }
  130. {
  131. const SFileVersion& ver = gEnv->pSystem->GetProductVersion();
  132. ver.ToString(s, sizeof(s));
  133. KeyValue(f, "ProductVersion", s);
  134. }
  135. if (m_eWorkMode == eWM_HTML)
  136. {
  137. fprintf(f, "<br>\n");
  138. }
  139. }
  140. void CConsoleHelpGen::StartH1(FILE* f, const char* szName) const
  141. {
  142. if (m_eWorkMode == eWM_HTML)
  143. {
  144. fprintf(f, "<h1>%s</h1>\n", szName);
  145. }
  146. else if (m_eWorkMode == eWM_Confluence)
  147. {
  148. fprintf(f, "h1. %s\n", szName);
  149. }
  150. else
  151. {
  152. assert(0);
  153. }
  154. }
  155. void CConsoleHelpGen::EndH1(FILE* f) const
  156. {
  157. if (m_eWorkMode == eWM_HTML)
  158. {
  159. fprintf(f, "<br>\n");
  160. }
  161. }
  162. void CConsoleHelpGen::StartH3(FILE* f, const char* szName) const
  163. {
  164. if (m_eWorkMode == eWM_HTML)
  165. {
  166. fprintf(f, "<h3>%s</h3><ul>\n", szName);
  167. }
  168. else if (m_eWorkMode == eWM_Confluence)
  169. {
  170. fprintf(f, "\nh3. %s\n", szName);
  171. }
  172. else
  173. {
  174. assert(0);
  175. }
  176. }
  177. void CConsoleHelpGen::EndH3(FILE* f) const
  178. {
  179. if (m_eWorkMode == eWM_HTML)
  180. {
  181. fprintf(f, "</ul>\n");
  182. }
  183. else if (m_eWorkMode == eWM_Confluence)
  184. {
  185. }
  186. else
  187. {
  188. assert(0);
  189. }
  190. }
  191. void CConsoleHelpGen::StartCVar(FILE* f, const char* szName) const
  192. {
  193. if (m_eWorkMode == eWM_HTML)
  194. {
  195. fprintf(f, "<h3>%s</h3><ul>\n", szName);
  196. }
  197. else if (m_eWorkMode == eWM_Confluence)
  198. {
  199. // fprintf(f,"\nh3. %s\n",szName);
  200. fprintf(f, "\n<div class=\"panel\" style=\"border-style: none;border-width: 1px;\"><div class=\"panelContent\"><p><b>%s</b><br/>\n", szName);
  201. }
  202. else
  203. {
  204. assert(0);
  205. }
  206. }
  207. void CConsoleHelpGen::EndCVar(FILE* f) const
  208. {
  209. if (m_eWorkMode == eWM_HTML)
  210. {
  211. fprintf(f, "</ul>\n");
  212. }
  213. else if (m_eWorkMode == eWM_Confluence)
  214. {
  215. fprintf(f, "</div></div>\n\n");
  216. }
  217. else
  218. {
  219. assert(0);
  220. }
  221. }
  222. void CConsoleHelpGen::SingleLinePrefix(FILE* f, const char* szPrefix, const char* szPrefixDesc, const char* szLink) const
  223. {
  224. // group within the list of all groups (no elements)
  225. if (m_eWorkMode == eWM_HTML)
  226. {
  227. fprintf(f, "<li><a href=\"%s\">%s_ %s</a></li>\n", szLink, szPrefix, szPrefixDesc);
  228. }
  229. else if (m_eWorkMode == eWM_Confluence)
  230. {
  231. AZStd::string sPrefix;
  232. if (*szPrefix)
  233. {
  234. sPrefix = AZStd::string(szPrefix) + "_";
  235. }
  236. // fprintf(f,"| %s | [%s|%s] |\n",sPrefix.c_str(),szPrefixDesc,szLink); // e.g. "" "CL_" "CC_" "I_" "T_"
  237. fprintf(f, "{section:border=false}\n"
  238. "{column:width=50px}{align:right}%s{align}{column}\n"
  239. "{column:width=10px}{column}\n"
  240. "{column}{align:left}[%s|%s]{align}{column}\n"
  241. "{section}\n",
  242. sPrefix.c_str(), szPrefixDesc, szLink); // e.g. "" "CL_" "CC_" "I_" "T_"
  243. }
  244. else
  245. {
  246. assert(0);
  247. }
  248. }
  249. void CConsoleHelpGen::StartPrefix(FILE* f, const char* szPrefix, const char* szPrefixDesc, const char* szLink) const
  250. {
  251. // group before all the group elements
  252. if (m_eWorkMode == eWM_HTML)
  253. {
  254. fprintf(f, "<li><a href=\"%s\">%s_ %s</li></a><ul>\n", szLink, szPrefix, szPrefixDesc);
  255. }
  256. else if (m_eWorkMode == eWM_Confluence)
  257. {
  258. if (*szPrefix)
  259. {
  260. fprintf(f, "* [%s %s|%s]\n", szPrefix, szPrefixDesc, szLink);
  261. }
  262. else
  263. {
  264. fprintf(f, "* [%s|%s]\n", szPrefixDesc, szLink);
  265. }
  266. }
  267. else
  268. {
  269. assert(0);
  270. }
  271. }
  272. void CConsoleHelpGen::EndPrefix(FILE* f) const
  273. {
  274. if (m_eWorkMode == eWM_HTML)
  275. {
  276. fprintf(f, "</ul>\n");
  277. }
  278. }
  279. void CConsoleHelpGen::SingleLineEntry_InGlobal(FILE* f, const char* szName, const char* szLink) const
  280. {
  281. // element within a group
  282. if (m_eWorkMode == eWM_HTML)
  283. {
  284. fprintf(f, "<li><a href=\"%s\">%s</a></li>\n", szLink, szName);
  285. }
  286. else if (m_eWorkMode == eWM_Confluence)
  287. {
  288. fprintf(f, "** [%s|%s]\n", szName, szLink);
  289. }
  290. else
  291. {
  292. assert(0);
  293. }
  294. }
  295. void CConsoleHelpGen::SingleLineEntry_InGroup(FILE* f, const char* szName, const char* szLink) const
  296. {
  297. // element within a group
  298. if (m_eWorkMode == eWM_HTML)
  299. {
  300. fprintf(f, "<li><a href=\"%s\">%s</a></li>\n", szLink, szName);
  301. }
  302. else if (m_eWorkMode == eWM_Confluence)
  303. {
  304. fprintf(f, "* [%s|%s]\n", szName, szLink);
  305. }
  306. else
  307. {
  308. assert(0);
  309. }
  310. }
  311. // szName without #
  312. void CConsoleHelpGen::Anchor(FILE* f, const char* szName) const
  313. {
  314. if (m_eWorkMode == eWM_HTML)
  315. {
  316. fprintf(f, "<a name=\"%s\"></a>\n", szName);
  317. }
  318. else if (m_eWorkMode == eWM_Confluence)
  319. {
  320. fprintf(f, "{anchor:%s}", szName);
  321. }
  322. else
  323. {
  324. assert(0);
  325. }
  326. }
  327. void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, const char* szLocalPrefix) const
  328. {
  329. CXConsole::ConsoleVariablesMap::const_iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end();
  330. for (itrVar = m_rParent.m_mapVariables.begin(); itrVar != itrVarEnd; ++itrVar)
  331. {
  332. ICVar* var = itrVar->second;
  333. if (_strnicmp(var->GetName(), szLocalPrefix, strlen(szLocalPrefix)) == 0)
  334. {
  335. setCmdAndVars.insert(var->GetName());
  336. }
  337. }
  338. }
  339. void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, const char* szLocalPrefix) const
  340. {
  341. CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
  342. for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
  343. {
  344. const CConsoleCommand& cmd = itrCmd->second;
  345. if (_strnicmp(cmd.m_sName.c_str(), szLocalPrefix, strlen(szLocalPrefix)) == 0)
  346. {
  347. setCmdAndVars.insert(cmd.m_sName.c_str());
  348. }
  349. }
  350. }
  351. void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const
  352. {
  353. CXConsole::ConsoleVariablesMap::const_iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end();
  354. for (itrVar = m_rParent.m_mapVariables.begin(); itrVar != itrVarEnd; ++itrVar)
  355. {
  356. ICVar* var = itrVar->second;
  357. bool bInsert = true;
  358. {
  359. std::map<AZStd::string, const char*>::const_iterator it2, end = mapPrefix.end();
  360. for (it2 = mapPrefix.begin(); it2 != end; ++it2)
  361. {
  362. if (it2->first != "___" && _strnicmp(var->GetName(), it2->first.c_str(), it2->first.size()) == 0)
  363. {
  364. bInsert = false;
  365. break;
  366. }
  367. }
  368. }
  369. if (bInsert)
  370. {
  371. setCmdAndVars.insert(var->GetName());
  372. }
  373. }
  374. }
  375. void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const
  376. {
  377. CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
  378. for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
  379. {
  380. const CConsoleCommand& cmd = itrCmd->second;
  381. bool bInsert = true;
  382. {
  383. std::map<AZStd::string, const char*>::const_iterator it2, end = mapPrefix.end();
  384. for (it2 = mapPrefix.begin(); it2 != end; ++it2)
  385. {
  386. if (it2->first != "___" && _strnicmp(cmd.m_sName.c_str(), it2->first.c_str(), it2->first.size()) == 0)
  387. {
  388. bInsert = false;
  389. break;
  390. }
  391. }
  392. }
  393. if (bInsert)
  394. {
  395. setCmdAndVars.insert(cmd.m_sName.c_str());
  396. }
  397. }
  398. }
  399. void CConsoleHelpGen::CreateSingleEntryFile(const char* szName) const
  400. {
  401. assert(m_eWorkMode == eWM_Confluence); // only needed for confluence
  402. FILE* f3 = nullptr;
  403. azfopen(&f3, (AZStd::string(GetFolderName()) + GetFileExtension() + "/" + FixAnchorName(szName)).c_str(), "w");
  404. if (!f3)
  405. {
  406. assert(0);
  407. return; // error
  408. }
  409. // StartPage(f3,szName,""); // HTML style
  410. IncludeSingleEntry(f3, szName);
  411. // EndPage(f3); // HTML style
  412. fclose(f3);
  413. }
  414. const CConsoleCommand* CConsoleHelpGen::FindConsoleCommand(const char* szName) const
  415. {
  416. CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
  417. for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
  418. {
  419. const CConsoleCommand& cmd = itrCmd->second;
  420. if (strcmp(cmd.m_sName.c_str(), szName) == 0)
  421. {
  422. return &cmd;
  423. }
  424. }
  425. return 0;
  426. }
  427. void CConsoleHelpGen::IncludeSingleEntry(FILE* f, const char* szName) const
  428. {
  429. StartCVar(f, szName);
  430. uint32 dwFlags = 0;
  431. const char* szHelp = "";
  432. // slow but good for simpler code
  433. if (ICVar* pVar = gEnv->pConsole->GetCVar(szName))
  434. {
  435. dwFlags = pVar->GetFlags();
  436. szHelp = pVar->GetHelp();
  437. }
  438. else if (const CConsoleCommand* pCommand = FindConsoleCommand(szName))
  439. {
  440. dwFlags = pCommand->m_nFlags;
  441. szHelp = pCommand->m_sHelp.c_str();
  442. }
  443. else
  444. {
  445. assert(0); // internal error
  446. }
  447. const char* szFlags = CXConsole::GetFlagsString(dwFlags);
  448. if (*szFlags)
  449. {
  450. // fprintf(f3,"%%GRAY%% %s %%ENDCOLOR%%<br>\n",szFlags); // twiki style
  451. if (m_eWorkMode == eWM_HTML)
  452. {
  453. fprintf(f, "%s<br>\n", szFlags); // simple HTML style
  454. }
  455. else if (m_eWorkMode == eWM_Confluence)
  456. {
  457. fprintf(f, "<font color=\"#808080\">%s</font></p>\n", szFlags);
  458. }
  459. else
  460. {
  461. assert(0);
  462. }
  463. }
  464. if (*szHelp == 0)
  465. {
  466. // fprintf(f,"%%TODO%%\n"); // wiki style, in our wiki %TODO% is defined as <img src=\"%%ICONURL{todo}%%\" width=\"37\" height=\"16\" alt=\"TODO\" border=\"0\" />
  467. if (m_eWorkMode == eWM_HTML)
  468. {
  469. fprintf(f, "<blockquote></b>*TODO*</b></blockquote>\n"); // HTML style
  470. }
  471. else if (m_eWorkMode == eWM_Confluence)
  472. {
  473. fprintf(f, "{warning}TODO{warning}\n"); // Confluence style
  474. }
  475. else
  476. {
  477. assert(0);
  478. }
  479. }
  480. else
  481. {
  482. if (m_eWorkMode == eWM_HTML)
  483. {
  484. fprintf(f, "<blockquote><pre><verbatim><tt>\n%s\n</tt></verbatim></pre></blockquote>\n", szHelp); // HTML style, <tt> to get fixed with font (layout in code is often making the assumption the forn is fixed width)
  485. }
  486. else if (m_eWorkMode == eWM_Confluence)
  487. {
  488. fprintf(f, "<pre>\n");
  489. AZStd::string sHelp = szHelp;
  490. // currently not required as the {noformat} is used
  491. // sHelp.replace("[","\\["); sHelp.replace("]","\\]");
  492. // sHelp.replace("{","\\{"); sHelp.replace("}","\\}");
  493. // sHelp.replace("(","\\("); sHelp.replace(")","\\)");
  494. fprintf(f, "%s\n", sHelp.c_str()); // Confluence style
  495. fprintf(f, "</pre>");
  496. }
  497. else
  498. {
  499. assert(0);
  500. }
  501. }
  502. EndCVar(f);
  503. }
  504. void CConsoleHelpGen::Work()
  505. {
  506. // AZStd::string sEngineFolder = AZStd::string("@user@/")+GetFolderName();
  507. // gEnv->pCryPak->RemoveDir(sEngineFolder.c_str()); // todo: check if that works
  508. // gEnv->pFileIO->CreatePath(sEngineFolder.c_str());
  509. m_eWorkMode = eWM_HTML;
  510. CreateMainPages();
  511. m_eWorkMode = eWM_Confluence;
  512. CreateMainPages();
  513. CreateFileForEachEntry();
  514. m_eWorkMode = eWM_None;
  515. }
  516. void CConsoleHelpGen::CreateFileForEachEntry()
  517. {
  518. assert(m_eWorkMode == eWM_Confluence); // only needed for confluence
  519. // generate a single file for each console command
  520. {
  521. CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
  522. for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
  523. {
  524. const CConsoleCommand& cmd = itrCmd->second;
  525. CreateSingleEntryFile(cmd.m_sName.c_str());
  526. }
  527. }
  528. // generate a single file for each console variable
  529. {
  530. CXConsole::ConsoleVariablesMap::iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end();
  531. for (itrVar = m_rParent.m_mapVariables.begin(); itrVar != itrVarEnd; ++itrVar)
  532. {
  533. ICVar* var = itrVar->second;
  534. CreateSingleEntryFile(var->GetName());
  535. }
  536. }
  537. }
  538. void CConsoleHelpGen::CreateMainPages()
  539. {
  540. gEnv->pFileIO->CreatePath(GetFolderName());
  541. std::map<AZStd::string, const char*> mapPrefix;
  542. // order here doesn't matter, after the name some help can be added (after the first return)
  543. mapPrefix[ "AI_"] = "Artificial Intelligence";
  544. mapPrefix[ "NET_"] = "Network";
  545. mapPrefix[ "ED_"] = "Editor";
  546. mapPrefix[ "ES_"] = "Entity System";
  547. mapPrefix[ "CON_"] = "Console";
  548. mapPrefix[ "AG_"] = "Animation Graph" "\n" "High level animation logic, describes animation selection and flow, matches animation state to current game logical state.";
  549. mapPrefix[ "AC_"] = "Animated Character" "\n" "Better name would be 'Character Movement'.\nBridges game controlled movement and animation controlled movement.";
  550. mapPrefix[ "CA_"] = "Character Animation" "\n" "Motion synthesize and playback, parameterization through blending and inversed kinematics.";
  551. mapPrefix[ "E_"] = "3DEngine";
  552. mapPrefix[ "I_"] = "Input";
  553. mapPrefix[ "FG_"] = "Flow Graph" "\n" "hyper graph: game logic";
  554. mapPrefix[ "P_"] = "Physics";
  555. mapPrefix[ "R_"] = "Renderer";
  556. mapPrefix[ "S_"] = "Sound";
  557. mapPrefix[ "G_"] = "Game" "\n" "game specific, not part of CryEngine";
  558. mapPrefix[ "SYS_"] = "System";
  559. mapPrefix[ "V_"] = "Vehicle";
  560. mapPrefix[ "FT_"] = "Feature Test";
  561. mapPrefix[ "DEMO_"] = "Time Demo";
  562. mapPrefix[ "FT_"] = "Feature Test";
  563. mapPrefix[ "GL_"] = "Game Lobby";
  564. mapPrefix[ "HUD_"] = "Heads Up Display";
  565. mapPrefix[ "KC_"] = "Kill Cam";
  566. mapPrefix[ "PL_"] = "Player";
  567. mapPrefix[ "PP_"] = "Player Progression";
  568. mapPrefix[ "AIM_"] = "Aiming";
  569. mapPrefix["CAPTURE_"] = "Capture";
  570. mapPrefix[ "DS_"] = "Dialog Scripts";
  571. mapPrefix[ "GT_"] = "Game Token";
  572. mapPrefix[ "LOG_"] = "Logging";
  573. mapPrefix[ "MOV_"] = "Movie Sequences";
  574. mapPrefix[ "OSM_"] = "Overload Scene Manager";
  575. mapPrefix["PROFILE_"] = "Profiling";
  576. mapPrefix[ "STAP_"] = "Screen-space Torso Aim Pose";
  577. mapPrefix[ "LUA_"] = "Lua" "\n" "scripting system";
  578. mapPrefix[ "SV_"] = "Server";
  579. mapPrefix[ "MFX_"] = "Material Effects";
  580. mapPrefix[ "M_"] = "Multi threading";
  581. mapPrefix[ "CC_"] = "Character Customization";
  582. mapPrefix[ "CL_"] = "Client";
  583. mapPrefix[ "Q_"] = "Quality" "\n" "usually shader quality";
  584. mapPrefix[ "T_"] = "Timer";
  585. mapPrefix[ "___"] = "Remaining"; // key defined to get it sorted in the end
  586. FILE* f1 = nullptr;
  587. azfopen(&f1, (AZStd::string(GetFolderName()) + "/index" + GetFileExtension()).c_str(), "w");
  588. if (!f1)
  589. {
  590. return;
  591. }
  592. StartPage(f1, "CryEngine ConsoleHTMLHelp", "main page");
  593. StartH1(f1, "Console Commands and Variables");
  594. LogVersion(f1);
  595. if (m_eWorkMode == eWM_HTML)
  596. {
  597. fprintf(f1, "This list was exported from the engine by using the <b>DumpCommandsVars</b> console command.<br>\n\n");
  598. }
  599. else if (m_eWorkMode == eWM_Confluence)
  600. {
  601. fprintf(f1, "This list was exported from the engine by using the *DumpCommandsVars* console command.\n\n");
  602. }
  603. else
  604. {
  605. assert(0);
  606. }
  607. // show all registered Prefix with one line
  608. {
  609. std::map<AZStd::string, const char*>::const_iterator it, end = mapPrefix.end();
  610. StartH3(f1, "Registered Prefixes");
  611. for (it = mapPrefix.begin(); it != end; ++it)
  612. {
  613. const char* szLocalPrefix = it->first.c_str(); // can be 0 for remaining ones
  614. AZStd::string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
  615. AZStd::string sPrefixName = SplitPrefixString_Part1(it->second);
  616. SingleLinePrefix(f1, sCleanPrefix.c_str(), sPrefixName.c_str(), (AZStd::string("CONSOLEPREFIX") + FixAnchorName(sCleanPrefix.c_str()) + GetFileExtension()).c_str());
  617. // fprintf(f1," * [[CONSOLEPREFIX%s][%s_ %s]]\n",FixAnchorName(sCleanPrefix.c_str()).c_str(),sCleanPrefix.c_str(),sPrefixName.c_str());
  618. }
  619. EndH3(f1); // Registered prefixes
  620. }
  621. {
  622. std::map<AZStd::string, const char*>::const_iterator it, it2, end = mapPrefix.end();
  623. StartH3(f1, "Console Commands and Variables Sorted by Prefix");
  624. for (it = mapPrefix.begin(); it != end; ++it)
  625. {
  626. const char* szLocalPrefix = it->first.c_str(); // can be 0 for remaining ones
  627. AZStd::string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
  628. AZStd::string sPrefixName = SplitPrefixString_Part1(it->second);
  629. std::set<const char*, string_nocase_lt> setCmdAndVars; // to get console variables and commands sorted together
  630. if (strcmp("___", szLocalPrefix) != 0)
  631. {
  632. // insert all starting with the prefix
  633. InsertConsoleVars(setCmdAndVars, szLocalPrefix);
  634. InsertConsoleCommands(setCmdAndVars, szLocalPrefix);
  635. }
  636. else
  637. {
  638. // insert all not starting with any of the prefix
  639. InsertConsoleVars(setCmdAndVars, mapPrefix);
  640. InsertConsoleCommands(setCmdAndVars, mapPrefix);
  641. }
  642. // -------------------------------
  643. AZStd::string sSubName = AZStd::string("CONSOLEPREFIX") + sCleanPrefix;
  644. StartPrefix(f1, sCleanPrefix.c_str(), sPrefixName.c_str(), (sSubName + GetFileExtension()).c_str());
  645. AZStd::string sFileOut = AZStd::string(GetFolderName()) + "/" + sSubName + GetFileExtension();
  646. FILE* f2 = nullptr;
  647. azfopen(&f2, sFileOut.c_str(), "w");
  648. if (!f2)
  649. {
  650. fclose(f1);
  651. return;
  652. }
  653. // headline
  654. {
  655. AZStd::string sHeadline;
  656. if (sCleanPrefix.empty())
  657. {
  658. sHeadline = "Console Commands and Variables Without Special Prefix";
  659. }
  660. else
  661. {
  662. sHeadline = AZStd::string("Console Commands and Variables with Prefix ") + sCleanPrefix + "_";
  663. }
  664. StartH1(f2, sHeadline.c_str());
  665. }
  666. Explanation(f2, SplitPrefixString_Part2(it->second));
  667. KeyValue(f2, "Possible Flags", CXConsole::GetFlagsString(0xffffffff));
  668. // fprintf(f2,"<b>Possible Flags:</b><br>\n");
  669. // fprintf(f2," <blockquote>%s</blockquote>",CXConsole::GetFlagsString(0xffffffff));
  670. // log console variables and commands
  671. {
  672. StartH3(f2, "Alphabetically Sorted");
  673. std::set<const char*, string_nocase_lt>::const_iterator itI, endI = setCmdAndVars.end();
  674. for (itI = setCmdAndVars.begin(); itI != endI; ++itI)
  675. {
  676. SingleLineEntry_InGlobal(f1, *itI, (sSubName + GetFileExtension() + "#Anchor" + FixAnchorName(*itI)).c_str());
  677. SingleLineEntry_InGroup(f2, *itI, (AZStd::string("#Anchor") + FixAnchorName(*itI)).c_str());
  678. }
  679. EndH3(f2);
  680. }
  681. {
  682. StartH3(f2, "Console Variables and Commands");
  683. bool bFirst = true;
  684. {
  685. std::set<const char*, string_nocase_lt>::const_iterator itI, endI = setCmdAndVars.end();
  686. for (itI = setCmdAndVars.begin(); itI != endI; ++itI)
  687. {
  688. if (!bFirst)
  689. {
  690. Separator(f2);
  691. }
  692. bFirst = false;
  693. Anchor(f2, (AZStd::string("Anchor") + FixAnchorName(*itI)).c_str()); // anchor
  694. IncludeSingleEntry(f2, *itI);
  695. }
  696. }
  697. EndH3(f2);
  698. }
  699. EndH1(f2); // Console Commands and Variables ...
  700. fclose(f2);
  701. f2 = 0;
  702. EndPrefix(f1);
  703. }
  704. EndH3(f1); // Console commands and variables sorted by prefix
  705. }
  706. EndH1(f1);
  707. EndPage(f1);
  708. fclose(f1);
  709. m_rParent.ConsoleLogInputResponse("successfully wrote directory %s", GetFolderName());
  710. }
  711. void CConsoleHelpGen::Separator(FILE* f) const
  712. {
  713. if (m_eWorkMode == eWM_HTML)
  714. {
  715. fprintf(f, "<hr>\n");
  716. }
  717. else if (m_eWorkMode == eWM_Confluence)
  718. {
  719. // fprintf(f,"----\n");
  720. }
  721. else
  722. {
  723. assert(0);
  724. }
  725. }
  726. void CConsoleHelpGen::Explanation(FILE* f, const char* szText) const
  727. {
  728. if (m_eWorkMode == eWM_HTML)
  729. {
  730. fprintf(f, "<blockquote>%s</blockquote><br>\n<br>\n", szText);
  731. }
  732. else if (m_eWorkMode == eWM_Confluence)
  733. {
  734. // fprintf(f,"{quote}%s{quote}\n\n",szText);
  735. fprintf(f, "%s\n\n", szText);
  736. }
  737. else
  738. {
  739. assert(0);
  740. }
  741. }
  742. const char* CConsoleHelpGen::GetFileExtension() const
  743. {
  744. if (m_eWorkMode == eWM_HTML)
  745. {
  746. return ".html";
  747. }
  748. else if (m_eWorkMode == eWM_Confluence)
  749. {
  750. }
  751. else
  752. {
  753. assert(0);
  754. }
  755. return "";
  756. }
  757. const char* CConsoleHelpGen::GetFolderName() const
  758. {
  759. if (m_eWorkMode == eWM_HTML)
  760. {
  761. return "ConsoleHTMLHelp";
  762. }
  763. else if (m_eWorkMode == eWM_Confluence)
  764. {
  765. return "ConsoleHTMLHelp/CRYAUTOGEN";
  766. }
  767. else
  768. {
  769. assert(0);
  770. }
  771. return 0;
  772. }
  773. #endif // defined(WIN32) || defined(WIN64)