|
15 | 15 | #include "launchoptions.hpp"
|
16 | 16 |
|
17 | 17 | #define CMENU_KEY_ALIAS_LENGTH 11 /* length of "_cmenu.key_" */
|
18 |
| - |
19 |
| -extern std::deque<Parser::MenuToken*> CMenuTokens; |
20 |
| -extern std::deque<Token> Tokens; |
21 |
| -extern std::deque<Token> ErrorTokens; // |
| 18 | +extern std::deque<Token> ErrorTokens; |
22 | 19 | std::deque<CommandMenu> CMenuContainer;
|
23 | 20 | std::map<std::string,std::string> KVMap={
|
24 | 21 | {"linger_time","0"},
|
@@ -72,9 +69,12 @@ int main(int argc, char** argv) {
|
72 | 69 | std::filesystem::create_directories(sOutputDir.string()+"/cfg");
|
73 | 70 | // Main CFG file that initializes our CMenus.
|
74 | 71 | std::ofstream InitRoutineFile(sOutputDir.string()+"/cfg/cmenu_initialize.cfg");
|
75 |
| - InitRoutineFile<<R"(closecaption 1 |
76 |
| -cc_lang commandmenu |
77 |
| -alias _cmenu.nullkeys"alias _cmenu.1 ; alias _cmenu.2 ; alias _cmenu.3 ; alias _cmenu.4 ; alias _cmenu.5 ; alias _cmenu.6 ; alias _cmenu.7 ; alias _cmenu.8 ; alias _cmenu.9; alias _cmenu.0" |
| 72 | + InitRoutineFile<<"closecaption 1\ncc_lang commandmenu\nalias _cmenu.nullkeys \""; |
| 73 | + std::for_each(UsedKeys.cbegin(), UsedKeys.cend(), |
| 74 | + [&InitRoutineFile](const std::string_view key){ |
| 75 | + InitRoutineFile<<"alias _cmenu.key_"<<((key.length() + CMENU_KEY_ALIAS_LENGTH > 32 ) ? key.substr(0, key.length() - CMENU_KEY_ALIAS_LENGTH) : key) << ';'; |
| 76 | + }); |
| 77 | + InitRoutineFile<<R"(" |
78 | 78 | alias cmenu.exitmenu"cc_emit _#cmenu.clear_screen;)"<<"cc_linger_time "<<KVMap["linger_time"]<<";cc_predisplay_time "<<KVMap["predisplay_time"]<<';'<<KVMap["resetkeys"]<<"; cmenu.on_exitmenu\"";
|
79 | 79 | InitRoutineFile<<R"(
|
80 | 80 | alias cmenu.on_exitmenu ;
|
@@ -105,11 +105,10 @@ cmenu.exitmenu
|
105 | 105 | /* Create the actual binds needed for the declared binds. */
|
106 | 106 | if (CMenu->Display == CMenuDisplayType::CAPTIONS) CMenuCFG<<"cc_linger_time 10000\ncc_predisplay_time 0\ncc_emit _#cmenu.clear_screen\ncc_emit _#cmenu."+CMenu->sRawName+'\n';
|
107 | 107 | else if (CMenu->Display == CMenuDisplayType::CONSOLE) CMenuCFG<<"developer 1\nclear\n";
|
108 |
| - for (auto& key : UsedKeys) { |
109 |
| - // Compress keynames so that it can fit in an alias |
110 |
| - CMenuCFG<<"bind "<<key<<" _cmenu.key_"<<((key.length() + CMENU_KEY_ALIAS_LENGTH > 32 ) ? key.substr(0, key.length() - CMENU_KEY_ALIAS_LENGTH) : key)<<'\n'; |
111 |
| - } |
112 |
| - |
| 108 | + // Compress keynames so that it can fit in an alias |
| 109 | + std::for_each(UsedKeys.cbegin(), UsedKeys.cend(), |
| 110 | + [&CMenuCFG](const std::string_view key){ CMenuCFG<<"bind "<<key<<" _cmenu.key_"<<((key.length() + CMENU_KEY_ALIAS_LENGTH > 32 ) ? key.substr(0, key.length() - CMENU_KEY_ALIAS_LENGTH) : key)<<'\n'; |
| 111 | + }); |
113 | 112 | {
|
114 | 113 | unsigned int t_ToggleNum=iToggleNumber;
|
115 | 114 | for (auto kTBind=CMenu->binds.begin(); kTBind!=CMenu->binds.end(); kTBind++) {
|
|
0 commit comments