123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #if defined(WIN32) || defined(WIN64)
- #include "CrySystem_precompiled.h"
- #include "ConsoleHelpGen.h"
- #include "System.h"
- #include <AzCore/Utils/Utils.h>
- // remove bad characters, toupper, not very fast
- AZStd::string CConsoleHelpGen::FixAnchorName(const char* szName)
- {
- AZStd::string ret;
- const char* p = szName;
- while (*p)
- {
- if ((*p >= 'a' && *p <= 'z')
- || (*p >= 'A' && *p <= 'Z')
- || (*p >= '0' && *p <= '9'))
- {
- if (*p >= 'a' && *p <= 'z')
- {
- ret += *p - 'a' + 'A';
- }
- else
- {
- ret += *p;
- }
- }
- ++p;
- }
- return ret;
- }
- AZStd::string CConsoleHelpGen::GetCleanPrefix(const char* p)
- {
- AZStd::string sRet;
- while (*p != '_' && *p != 0)
- {
- sRet += *p++;
- }
- return sRet;
- }
- AZStd::string CConsoleHelpGen::SplitPrefixString_Part1(const char* p)
- {
- AZStd::string sRet;
- while (*p != 10 && *p != 13 && *p != 0)
- {
- sRet += *p++;
- }
- return sRet;
- }
- const char* CConsoleHelpGen::SplitPrefixString_Part2(const char* p)
- {
- while (*p != 10 && *p != 13 && *p != 0)
- {
- p++;
- }
- while (*p == 10 || *p == 13)
- {
- p++;
- }
- return p;
- }
- void CConsoleHelpGen::StartPage(FILE* f, const char* szPageName, const char* szPageDescription) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<HTML><HEAD><TITLE>%s</TITLE><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">", szPageName);
- fprintf(f, "<META NAME=\"DESCRIPTION\" CONTENT=\"%s\">", szPageDescription);
- fprintf(f, "<META NAME=\"author\" content=\"Contributors to the Open 3D Engine Project\">");
- fprintf(f, "<META NAME=\"copyright\" CONTENT=\"Contributors to the Open 3D Engine Project\">");
- fprintf(f, "<META NAME=\"KEYWORDS\" CONTENT=\"O3DE\">");
- fprintf(f, "<META NAME=\"distribution\" CONTENT=\"Contributors to the Open 3D Engine Project\">");
- fprintf(f, "<META NAME=\"revisit-after\" CONTENT=\"10 days\">");
- fprintf(f, "<META NAME=\"robots\" CONTENT=\"INDEX, NOFOLLOW\">");
- fprintf(f, "</HEAD><BODY bgcolor=#ffffff leftmargin=0 topmargin=0 alink=#0000ff link=#0000ff vlink=#0000ff text=#000000>");
- }
- }
- void CConsoleHelpGen::EndPage(FILE* f) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<P></P></BODY></HTML>");
- }
- }
- void CConsoleHelpGen::KeyValue(FILE* f, const char* szKey, const char* szValue) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<b>%s:</b> %s<br>\n", szKey, szValue);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- // fprintf(f,"*%s:* %s\n",szKey,szValue);
- fprintf(f, "| *%s:* | %s |\n", szKey, szValue);
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::LogVersion(FILE* f) const
- {
- char s[1024];
- {
- AZ::Utils::GetExecutablePath(s, 1024);
- char fdir[_MAX_PATH];
- char fdrive[_MAX_PATH];
- char file[_MAX_PATH];
- char fext[_MAX_PATH];
- _splitpath_s(s, fdrive, fdir, file, fext);
- KeyValue(f, "Executable", (AZStd::string(file) + fext).c_str());
- }
- {
- time_t ltime;
- time(<ime);
- tm today;
- localtime_s(&today, <ime);
- strftime(s, 128, "%c", &today);
- KeyValue(f, "Date(MM/DD/YY) Time", s);
- }
- {
- const SFileVersion& ver = gEnv->pSystem->GetFileVersion();
- ver.ToString(s, sizeof(s));
- KeyValue(f, "FileVersion", s);
- }
- {
- const SFileVersion& ver = gEnv->pSystem->GetProductVersion();
- ver.ToString(s, sizeof(s));
- KeyValue(f, "ProductVersion", s);
- }
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<br>\n");
- }
- }
- void CConsoleHelpGen::StartH1(FILE* f, const char* szName) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<h1>%s</h1>\n", szName);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "h1. %s\n", szName);
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::EndH1(FILE* f) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<br>\n");
- }
- }
- void CConsoleHelpGen::StartH3(FILE* f, const char* szName) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<h3>%s</h3><ul>\n", szName);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "\nh3. %s\n", szName);
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::EndH3(FILE* f) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "</ul>\n");
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::StartCVar(FILE* f, const char* szName) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<h3>%s</h3><ul>\n", szName);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- // fprintf(f,"\nh3. %s\n",szName);
- fprintf(f, "\n<div class=\"panel\" style=\"border-style: none;border-width: 1px;\"><div class=\"panelContent\"><p><b>%s</b><br/>\n", szName);
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::EndCVar(FILE* f) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "</ul>\n");
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "</div></div>\n\n");
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::SingleLinePrefix(FILE* f, const char* szPrefix, const char* szPrefixDesc, const char* szLink) const
- {
- // group within the list of all groups (no elements)
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<li><a href=\"%s\">%s_ %s</a></li>\n", szLink, szPrefix, szPrefixDesc);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- AZStd::string sPrefix;
- if (*szPrefix)
- {
- sPrefix = AZStd::string(szPrefix) + "_";
- }
- // fprintf(f,"| %s | [%s|%s] |\n",sPrefix.c_str(),szPrefixDesc,szLink); // e.g. "" "CL_" "CC_" "I_" "T_"
- fprintf(f, "{section:border=false}\n"
- "{column:width=50px}{align:right}%s{align}{column}\n"
- "{column:width=10px}{column}\n"
- "{column}{align:left}[%s|%s]{align}{column}\n"
- "{section}\n",
- sPrefix.c_str(), szPrefixDesc, szLink); // e.g. "" "CL_" "CC_" "I_" "T_"
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::StartPrefix(FILE* f, const char* szPrefix, const char* szPrefixDesc, const char* szLink) const
- {
- // group before all the group elements
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<li><a href=\"%s\">%s_ %s</li></a><ul>\n", szLink, szPrefix, szPrefixDesc);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- if (*szPrefix)
- {
- fprintf(f, "* [%s %s|%s]\n", szPrefix, szPrefixDesc, szLink);
- }
- else
- {
- fprintf(f, "* [%s|%s]\n", szPrefixDesc, szLink);
- }
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::EndPrefix(FILE* f) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "</ul>\n");
- }
- }
- void CConsoleHelpGen::SingleLineEntry_InGlobal(FILE* f, const char* szName, const char* szLink) const
- {
- // element within a group
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<li><a href=\"%s\">%s</a></li>\n", szLink, szName);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "** [%s|%s]\n", szName, szLink);
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::SingleLineEntry_InGroup(FILE* f, const char* szName, const char* szLink) const
- {
- // element within a group
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<li><a href=\"%s\">%s</a></li>\n", szLink, szName);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "* [%s|%s]\n", szName, szLink);
- }
- else
- {
- assert(0);
- }
- }
- // szName without #
- void CConsoleHelpGen::Anchor(FILE* f, const char* szName) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<a name=\"%s\"></a>\n", szName);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "{anchor:%s}", szName);
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, const char* szLocalPrefix) const
- {
- CXConsole::ConsoleVariablesMap::const_iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end();
- for (itrVar = m_rParent.m_mapVariables.begin(); itrVar != itrVarEnd; ++itrVar)
- {
- ICVar* var = itrVar->second;
- if (_strnicmp(var->GetName(), szLocalPrefix, strlen(szLocalPrefix)) == 0)
- {
- setCmdAndVars.insert(var->GetName());
- }
- }
- }
- void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, const char* szLocalPrefix) const
- {
- CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
- for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
- {
- const CConsoleCommand& cmd = itrCmd->second;
- if (_strnicmp(cmd.m_sName.c_str(), szLocalPrefix, strlen(szLocalPrefix)) == 0)
- {
- setCmdAndVars.insert(cmd.m_sName.c_str());
- }
- }
- }
- void CConsoleHelpGen::InsertConsoleVars(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const
- {
- CXConsole::ConsoleVariablesMap::const_iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end();
- for (itrVar = m_rParent.m_mapVariables.begin(); itrVar != itrVarEnd; ++itrVar)
- {
- ICVar* var = itrVar->second;
- bool bInsert = true;
- {
- std::map<AZStd::string, const char*>::const_iterator it2, end = mapPrefix.end();
- for (it2 = mapPrefix.begin(); it2 != end; ++it2)
- {
- if (it2->first != "___" && _strnicmp(var->GetName(), it2->first.c_str(), it2->first.size()) == 0)
- {
- bInsert = false;
- break;
- }
- }
- }
- if (bInsert)
- {
- setCmdAndVars.insert(var->GetName());
- }
- }
- }
- void CConsoleHelpGen::InsertConsoleCommands(std::set<const char*, string_nocase_lt>& setCmdAndVars, std::map<AZStd::string, const char*> mapPrefix) const
- {
- CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
- for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
- {
- const CConsoleCommand& cmd = itrCmd->second;
- bool bInsert = true;
- {
- std::map<AZStd::string, const char*>::const_iterator it2, end = mapPrefix.end();
- for (it2 = mapPrefix.begin(); it2 != end; ++it2)
- {
- if (it2->first != "___" && _strnicmp(cmd.m_sName.c_str(), it2->first.c_str(), it2->first.size()) == 0)
- {
- bInsert = false;
- break;
- }
- }
- }
- if (bInsert)
- {
- setCmdAndVars.insert(cmd.m_sName.c_str());
- }
- }
- }
- void CConsoleHelpGen::CreateSingleEntryFile(const char* szName) const
- {
- assert(m_eWorkMode == eWM_Confluence); // only needed for confluence
- FILE* f3 = nullptr;
- azfopen(&f3, (AZStd::string(GetFolderName()) + GetFileExtension() + "/" + FixAnchorName(szName)).c_str(), "w");
- if (!f3)
- {
- assert(0);
- return; // error
- }
- // StartPage(f3,szName,""); // HTML style
- IncludeSingleEntry(f3, szName);
- // EndPage(f3); // HTML style
- fclose(f3);
- }
- const CConsoleCommand* CConsoleHelpGen::FindConsoleCommand(const char* szName) const
- {
- CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
- for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
- {
- const CConsoleCommand& cmd = itrCmd->second;
- if (strcmp(cmd.m_sName.c_str(), szName) == 0)
- {
- return &cmd;
- }
- }
- return 0;
- }
- void CConsoleHelpGen::IncludeSingleEntry(FILE* f, const char* szName) const
- {
- StartCVar(f, szName);
- uint32 dwFlags = 0;
- const char* szHelp = "";
- // slow but good for simpler code
- if (ICVar* pVar = gEnv->pConsole->GetCVar(szName))
- {
- dwFlags = pVar->GetFlags();
- szHelp = pVar->GetHelp();
- }
- else if (const CConsoleCommand* pCommand = FindConsoleCommand(szName))
- {
- dwFlags = pCommand->m_nFlags;
- szHelp = pCommand->m_sHelp.c_str();
- }
- else
- {
- assert(0); // internal error
- }
- const char* szFlags = CXConsole::GetFlagsString(dwFlags);
- if (*szFlags)
- {
- // fprintf(f3,"%%GRAY%% %s %%ENDCOLOR%%<br>\n",szFlags); // twiki style
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "%s<br>\n", szFlags); // simple HTML style
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "<font color=\"#808080\">%s</font></p>\n", szFlags);
- }
- else
- {
- assert(0);
- }
- }
- if (*szHelp == 0)
- {
- // 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\" />
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<blockquote></b>*TODO*</b></blockquote>\n"); // HTML style
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "{warning}TODO{warning}\n"); // Confluence style
- }
- else
- {
- assert(0);
- }
- }
- else
- {
- if (m_eWorkMode == eWM_HTML)
- {
- 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)
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f, "<pre>\n");
- AZStd::string sHelp = szHelp;
- // currently not required as the {noformat} is used
- // sHelp.replace("[","\\["); sHelp.replace("]","\\]");
- // sHelp.replace("{","\\{"); sHelp.replace("}","\\}");
- // sHelp.replace("(","\\("); sHelp.replace(")","\\)");
- fprintf(f, "%s\n", sHelp.c_str()); // Confluence style
- fprintf(f, "</pre>");
- }
- else
- {
- assert(0);
- }
- }
- EndCVar(f);
- }
- void CConsoleHelpGen::Work()
- {
- // AZStd::string sEngineFolder = AZStd::string("@user@/")+GetFolderName();
- // gEnv->pCryPak->RemoveDir(sEngineFolder.c_str()); // todo: check if that works
- // gEnv->pFileIO->CreatePath(sEngineFolder.c_str());
- m_eWorkMode = eWM_HTML;
- CreateMainPages();
- m_eWorkMode = eWM_Confluence;
- CreateMainPages();
- CreateFileForEachEntry();
- m_eWorkMode = eWM_None;
- }
- void CConsoleHelpGen::CreateFileForEachEntry()
- {
- assert(m_eWorkMode == eWM_Confluence); // only needed for confluence
- // generate a single file for each console command
- {
- CXConsole::ConsoleCommandsMap::const_iterator itrCmd, itrCmdEnd = m_rParent.m_mapCommands.end();
- for (itrCmd = m_rParent.m_mapCommands.begin(); itrCmd != itrCmdEnd; ++itrCmd)
- {
- const CConsoleCommand& cmd = itrCmd->second;
- CreateSingleEntryFile(cmd.m_sName.c_str());
- }
- }
- // generate a single file for each console variable
- {
- CXConsole::ConsoleVariablesMap::iterator itrVar, itrVarEnd = m_rParent.m_mapVariables.end();
- for (itrVar = m_rParent.m_mapVariables.begin(); itrVar != itrVarEnd; ++itrVar)
- {
- ICVar* var = itrVar->second;
- CreateSingleEntryFile(var->GetName());
- }
- }
- }
- void CConsoleHelpGen::CreateMainPages()
- {
- gEnv->pFileIO->CreatePath(GetFolderName());
- std::map<AZStd::string, const char*> mapPrefix;
- // order here doesn't matter, after the name some help can be added (after the first return)
- mapPrefix[ "AI_"] = "Artificial Intelligence";
- mapPrefix[ "NET_"] = "Network";
- mapPrefix[ "ED_"] = "Editor";
- mapPrefix[ "ES_"] = "Entity System";
- mapPrefix[ "CON_"] = "Console";
- mapPrefix[ "AG_"] = "Animation Graph" "\n" "High level animation logic, describes animation selection and flow, matches animation state to current game logical state.";
- mapPrefix[ "AC_"] = "Animated Character" "\n" "Better name would be 'Character Movement'.\nBridges game controlled movement and animation controlled movement.";
- mapPrefix[ "CA_"] = "Character Animation" "\n" "Motion synthesize and playback, parameterization through blending and inversed kinematics.";
- mapPrefix[ "E_"] = "3DEngine";
- mapPrefix[ "I_"] = "Input";
- mapPrefix[ "FG_"] = "Flow Graph" "\n" "hyper graph: game logic";
- mapPrefix[ "P_"] = "Physics";
- mapPrefix[ "R_"] = "Renderer";
- mapPrefix[ "S_"] = "Sound";
- mapPrefix[ "G_"] = "Game" "\n" "game specific, not part of CryEngine";
- mapPrefix[ "SYS_"] = "System";
- mapPrefix[ "V_"] = "Vehicle";
- mapPrefix[ "FT_"] = "Feature Test";
- mapPrefix[ "DEMO_"] = "Time Demo";
- mapPrefix[ "FT_"] = "Feature Test";
- mapPrefix[ "GL_"] = "Game Lobby";
- mapPrefix[ "HUD_"] = "Heads Up Display";
- mapPrefix[ "KC_"] = "Kill Cam";
- mapPrefix[ "PL_"] = "Player";
- mapPrefix[ "PP_"] = "Player Progression";
- mapPrefix[ "AIM_"] = "Aiming";
- mapPrefix["CAPTURE_"] = "Capture";
- mapPrefix[ "DS_"] = "Dialog Scripts";
- mapPrefix[ "GT_"] = "Game Token";
- mapPrefix[ "LOG_"] = "Logging";
- mapPrefix[ "MOV_"] = "Movie Sequences";
- mapPrefix[ "OSM_"] = "Overload Scene Manager";
- mapPrefix["PROFILE_"] = "Profiling";
- mapPrefix[ "STAP_"] = "Screen-space Torso Aim Pose";
- mapPrefix[ "LUA_"] = "Lua" "\n" "scripting system";
- mapPrefix[ "SV_"] = "Server";
- mapPrefix[ "MFX_"] = "Material Effects";
- mapPrefix[ "M_"] = "Multi threading";
- mapPrefix[ "CC_"] = "Character Customization";
- mapPrefix[ "CL_"] = "Client";
- mapPrefix[ "Q_"] = "Quality" "\n" "usually shader quality";
- mapPrefix[ "T_"] = "Timer";
- mapPrefix[ "___"] = "Remaining"; // key defined to get it sorted in the end
- FILE* f1 = nullptr;
- azfopen(&f1, (AZStd::string(GetFolderName()) + "/index" + GetFileExtension()).c_str(), "w");
- if (!f1)
- {
- return;
- }
- StartPage(f1, "CryEngine ConsoleHTMLHelp", "main page");
- StartH1(f1, "Console Commands and Variables");
- LogVersion(f1);
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f1, "This list was exported from the engine by using the <b>DumpCommandsVars</b> console command.<br>\n\n");
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- fprintf(f1, "This list was exported from the engine by using the *DumpCommandsVars* console command.\n\n");
- }
- else
- {
- assert(0);
- }
- // show all registered Prefix with one line
- {
- std::map<AZStd::string, const char*>::const_iterator it, end = mapPrefix.end();
- StartH3(f1, "Registered Prefixes");
- for (it = mapPrefix.begin(); it != end; ++it)
- {
- const char* szLocalPrefix = it->first.c_str(); // can be 0 for remaining ones
- AZStd::string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
- AZStd::string sPrefixName = SplitPrefixString_Part1(it->second);
- SingleLinePrefix(f1, sCleanPrefix.c_str(), sPrefixName.c_str(), (AZStd::string("CONSOLEPREFIX") + FixAnchorName(sCleanPrefix.c_str()) + GetFileExtension()).c_str());
- // fprintf(f1," * [[CONSOLEPREFIX%s][%s_ %s]]\n",FixAnchorName(sCleanPrefix.c_str()).c_str(),sCleanPrefix.c_str(),sPrefixName.c_str());
- }
- EndH3(f1); // Registered prefixes
- }
- {
- std::map<AZStd::string, const char*>::const_iterator it, it2, end = mapPrefix.end();
- StartH3(f1, "Console Commands and Variables Sorted by Prefix");
- for (it = mapPrefix.begin(); it != end; ++it)
- {
- const char* szLocalPrefix = it->first.c_str(); // can be 0 for remaining ones
- AZStd::string sCleanPrefix = GetCleanPrefix(szLocalPrefix);
- AZStd::string sPrefixName = SplitPrefixString_Part1(it->second);
- std::set<const char*, string_nocase_lt> setCmdAndVars; // to get console variables and commands sorted together
- if (strcmp("___", szLocalPrefix) != 0)
- {
- // insert all starting with the prefix
- InsertConsoleVars(setCmdAndVars, szLocalPrefix);
- InsertConsoleCommands(setCmdAndVars, szLocalPrefix);
- }
- else
- {
- // insert all not starting with any of the prefix
- InsertConsoleVars(setCmdAndVars, mapPrefix);
- InsertConsoleCommands(setCmdAndVars, mapPrefix);
- }
- // -------------------------------
- AZStd::string sSubName = AZStd::string("CONSOLEPREFIX") + sCleanPrefix;
- StartPrefix(f1, sCleanPrefix.c_str(), sPrefixName.c_str(), (sSubName + GetFileExtension()).c_str());
- AZStd::string sFileOut = AZStd::string(GetFolderName()) + "/" + sSubName + GetFileExtension();
- FILE* f2 = nullptr;
- azfopen(&f2, sFileOut.c_str(), "w");
- if (!f2)
- {
- fclose(f1);
- return;
- }
- // headline
- {
- AZStd::string sHeadline;
- if (sCleanPrefix.empty())
- {
- sHeadline = "Console Commands and Variables Without Special Prefix";
- }
- else
- {
- sHeadline = AZStd::string("Console Commands and Variables with Prefix ") + sCleanPrefix + "_";
- }
- StartH1(f2, sHeadline.c_str());
- }
- Explanation(f2, SplitPrefixString_Part2(it->second));
- KeyValue(f2, "Possible Flags", CXConsole::GetFlagsString(0xffffffff));
- // fprintf(f2,"<b>Possible Flags:</b><br>\n");
- // fprintf(f2," <blockquote>%s</blockquote>",CXConsole::GetFlagsString(0xffffffff));
- // log console variables and commands
- {
- StartH3(f2, "Alphabetically Sorted");
- std::set<const char*, string_nocase_lt>::const_iterator itI, endI = setCmdAndVars.end();
- for (itI = setCmdAndVars.begin(); itI != endI; ++itI)
- {
- SingleLineEntry_InGlobal(f1, *itI, (sSubName + GetFileExtension() + "#Anchor" + FixAnchorName(*itI)).c_str());
- SingleLineEntry_InGroup(f2, *itI, (AZStd::string("#Anchor") + FixAnchorName(*itI)).c_str());
- }
- EndH3(f2);
- }
- {
- StartH3(f2, "Console Variables and Commands");
- bool bFirst = true;
- {
- std::set<const char*, string_nocase_lt>::const_iterator itI, endI = setCmdAndVars.end();
- for (itI = setCmdAndVars.begin(); itI != endI; ++itI)
- {
- if (!bFirst)
- {
- Separator(f2);
- }
- bFirst = false;
- Anchor(f2, (AZStd::string("Anchor") + FixAnchorName(*itI)).c_str()); // anchor
- IncludeSingleEntry(f2, *itI);
- }
- }
- EndH3(f2);
- }
- EndH1(f2); // Console Commands and Variables ...
- fclose(f2);
- f2 = 0;
- EndPrefix(f1);
- }
- EndH3(f1); // Console commands and variables sorted by prefix
- }
- EndH1(f1);
- EndPage(f1);
- fclose(f1);
- m_rParent.ConsoleLogInputResponse("successfully wrote directory %s", GetFolderName());
- }
- void CConsoleHelpGen::Separator(FILE* f) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<hr>\n");
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- // fprintf(f,"----\n");
- }
- else
- {
- assert(0);
- }
- }
- void CConsoleHelpGen::Explanation(FILE* f, const char* szText) const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- fprintf(f, "<blockquote>%s</blockquote><br>\n<br>\n", szText);
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- // fprintf(f,"{quote}%s{quote}\n\n",szText);
- fprintf(f, "%s\n\n", szText);
- }
- else
- {
- assert(0);
- }
- }
- const char* CConsoleHelpGen::GetFileExtension() const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- return ".html";
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- }
- else
- {
- assert(0);
- }
- return "";
- }
- const char* CConsoleHelpGen::GetFolderName() const
- {
- if (m_eWorkMode == eWM_HTML)
- {
- return "ConsoleHTMLHelp";
- }
- else if (m_eWorkMode == eWM_Confluence)
- {
- return "ConsoleHTMLHelp/CRYAUTOGEN";
- }
- else
- {
- assert(0);
- }
- return 0;
- }
- #endif // defined(WIN32) || defined(WIN64)
|