changeset 193 | 0a7025304867 |
parent 176 | 84990c4b9212 |
child 205 | 49e96fd94d63 |
192:614bba52258d | 193:0a7025304867 |
---|---|
42 |
42 |
43 // ** console parser ** // |
43 // ** console parser ** // |
44 static _iconsole_cmd * _iconsole_cmds; // list of registred commands |
44 static _iconsole_cmd * _iconsole_cmds; // list of registred commands |
45 static _iconsole_var * _iconsole_vars; // list of registred vars |
45 static _iconsole_var * _iconsole_vars; // list of registred vars |
46 |
46 |
47 // ** console std lib ** // |
47 // ** console std lib ** // |
48 static byte _stdlib_developer=1; |
48 static byte _stdlib_developer=1; |
49 static bool _stdlib_con_developer=false; |
49 static bool _stdlib_con_developer=false; |
50 static void IConsoleStdLibRegister(); |
50 static void IConsoleStdLibRegister(); |
51 |
51 |
52 /* *************** */ |
52 /* *************** */ |
94 posx=10+GetStringWidth((char *)&_iconsole_cmdline); |
94 posx=10+GetStringWidth((char *)&_iconsole_cmdline); |
95 posy=w->height-3; |
95 posy=w->height-3; |
96 GfxFillRect(posx,posy,posx+5,posy+1,color); |
96 GfxFillRect(posx,posy,posx+5,posy+1,color); |
97 _video_driver->make_dirty(posx,posy,5,1); |
97 _video_driver->make_dirty(posx,posy,5,1); |
98 } |
98 } |
99 _icursor_counter=0; |
99 _icursor_counter=0; |
100 } |
100 } |
101 break; |
101 break; |
102 |
102 |
103 case WE_DESTROY: |
103 case WE_DESTROY: |
104 _iconsole_win=NULL; |
104 _iconsole_win=NULL; |
155 } else |
155 } else |
156 if (e->keypress.keycode == WKC_BACKQUOTE) |
156 if (e->keypress.keycode == WKC_BACKQUOTE) |
157 { |
157 { |
158 IConsoleSwitch(); |
158 IConsoleSwitch(); |
159 } else |
159 } else |
160 if (e->keypress.keycode == WKC_RETURN) |
160 if (e->keypress.keycode == WKC_RETURN) |
161 { |
161 { |
162 IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline); |
162 IConsolePrintF(_iconsole_color_commands, "] %s", _iconsole_cmdline); |
163 IConsoleCmdBufferAdd(_iconsole_cmdline); |
163 IConsoleCmdBufferAdd(_iconsole_cmdline); |
164 IConsoleCmdExec((byte *) _iconsole_cmdline); |
164 IConsoleCmdExec((byte *) _iconsole_cmdline); |
165 IConsoleClearCommand(); |
165 IConsoleClearCommand(); |
166 } else |
166 } else |
167 if (e->keypress.keycode == WKC_BACKSPACE) |
167 if (e->keypress.keycode == WKC_BACKSPACE) |
168 { |
168 { |
169 if (_iconsole_cmdpos!=0) _iconsole_cmdpos--; |
169 if (_iconsole_cmdpos!=0) _iconsole_cmdpos--; |
170 _iconsole_cmdline[_iconsole_cmdpos]=0; |
170 _iconsole_cmdline[_iconsole_cmdpos]=0; |
171 SetWindowDirty(w); |
171 SetWindowDirty(w); |
172 _iconsole_cmdbufferpos=19; |
172 _iconsole_cmdbufferpos=19; |
173 } else |
173 } else |
174 if (IS_INT_INSIDE((e->keypress.ascii), 32, 256)) |
174 if (IS_INT_INSIDE((e->keypress.ascii), 32, 256)) |
175 { |
175 { |
176 _iconsole_scroll=79; |
176 _iconsole_scroll=79; |
177 _iconsole_cmdline[_iconsole_cmdpos]=e->keypress.ascii; |
177 _iconsole_cmdline[_iconsole_cmdpos]=e->keypress.ascii; |
178 if (_iconsole_cmdpos!=255) _iconsole_cmdpos++; |
178 if (_iconsole_cmdpos!=255) _iconsole_cmdpos++; |
179 SetWindowDirty(w); |
179 SetWindowDirty(w); |
180 _iconsole_cmdbufferpos=19; |
180 _iconsole_cmdbufferpos=19; |
181 } else e->keypress.cont=true; |
181 } else e->keypress.cont=true; |
182 break; |
182 break; |
183 |
183 |
184 } |
184 } |
185 } |
185 } |
186 |
186 |
209 _iconsole_buffer[i]=NULL; |
209 _iconsole_buffer[i]=NULL; |
210 _iconsole_cbuffer[i]=0; |
210 _iconsole_cbuffer[i]=0; |
211 } |
211 } |
212 IConsoleStdLibRegister(); |
212 IConsoleStdLibRegister(); |
213 #if defined(WITH_REV) |
213 #if defined(WITH_REV) |
214 IConsolePrintF(13,"OpenTTD Game Console Revision 3 - %s",_openttd_revision); |
214 IConsolePrintF(13,"OpenTTD Game Console Revision 3 - %s",_openttd_revision); |
215 #else |
215 #else |
216 IConsolePrint(13,"OpenTTD Game Console Revision 3"); |
216 IConsolePrint(13,"OpenTTD Game Console Revision 3"); |
217 #endif |
217 #endif |
218 IConsolePrint(12,"---------------------------------"); |
218 IConsolePrint(12,"---------------------------------"); |
219 IConsolePrint(12,"use \"help\" for more info"); |
219 IConsolePrint(12,"use \"help\" for more info"); |
220 IConsolePrint(12,""); |
220 IConsolePrint(12,""); |
221 IConsoleClearCommand(); |
221 IConsoleClearCommand(); |
384 |
384 |
385 void* IConsoleCmdGetAddr(byte * name) { |
385 void* IConsoleCmdGetAddr(byte * name) { |
386 _iconsole_cmd * item; |
386 _iconsole_cmd * item; |
387 |
387 |
388 item = _iconsole_cmds; |
388 item = _iconsole_cmds; |
389 while (item != NULL) { |
389 while (item != NULL) { |
390 if (strcmp(item->name,name)==0) return item->addr; |
390 if (strcmp(item->name,name)==0) return item->addr; |
391 item = item->_next; |
391 item = item->_next; |
392 } |
392 } |
393 return NULL; |
393 return NULL; |
394 } |
394 } |
453 |
453 |
454 _iconsole_var * IConsoleVarGet(byte * name) { |
454 _iconsole_var * IConsoleVarGet(byte * name) { |
455 _iconsole_var * item; |
455 _iconsole_var * item; |
456 |
456 |
457 item = _iconsole_vars; |
457 item = _iconsole_vars; |
458 while (item != NULL) { |
458 while (item != NULL) { |
459 if (strcmp(item->name,name)==0) return item; |
459 if (strcmp(item->name,name)==0) return item; |
460 item = item->_next; |
460 item = item->_next; |
461 } |
461 } |
462 return NULL; |
462 return NULL; |
463 } |
463 } |
731 |
731 |
732 tokenstream--; |
732 tokenstream--; |
733 if (!(*tokenstream==0)) { |
733 if (!(*tokenstream==0)) { |
734 c++; |
734 c++; |
735 tokenstream++; |
735 tokenstream++; |
736 *tokenstream = 0; |
736 *tokenstream = 0; |
737 } |
737 } |
738 |
738 |
739 //** interpreting **// |
739 //** interpreting **// |
740 |
740 |
741 for (i=0; i<c; i++) { |
741 for (i=0; i<c; i++) { |
788 } |
788 } |
789 |
789 |
790 //** executing **// |
790 //** executing **// |
791 if (_stdlib_con_developer) IConsolePrintF(_iconsole_color_debug,"CONDEBUG: execution_mode: %i",execution_mode); |
791 if (_stdlib_con_developer) IConsolePrintF(_iconsole_color_debug,"CONDEBUG: execution_mode: %i",execution_mode); |
792 switch (execution_mode) { |
792 switch (execution_mode) { |
793 case 0: |
793 case 0: |
794 { |
794 { |
795 // not found |
795 // not found |
796 IConsoleError("command or variable not found"); |
796 IConsoleError("command or variable not found"); |
797 } |
797 } |
798 break; |
798 break; |
828 IConsoleVarDump(var,NULL); |
828 IConsoleVarDump(var,NULL); |
829 } |
829 } |
830 else if (strcmp(tokens[1],"--")==0) { |
830 else if (strcmp(tokens[1],"--")==0) { |
831 *(bool *)var->addr=!*(bool *)var->addr; |
831 *(bool *)var->addr=!*(bool *)var->addr; |
832 IConsoleVarDump(var,NULL); |
832 IConsoleVarDump(var,NULL); |
833 } |
833 } |
834 else { IConsoleError("operation not supported"); } |
834 else { IConsoleError("operation not supported"); } |
835 } |
835 } |
836 break; |
836 break; |
837 case ICONSOLE_VAR_BYTE: |
837 case ICONSOLE_VAR_BYTE: |
838 { |
838 { |
850 IConsoleVarDump(var,NULL); |
850 IConsoleVarDump(var,NULL); |
851 } |
851 } |
852 else if (strcmp(tokens[1],"--")==0) { |
852 else if (strcmp(tokens[1],"--")==0) { |
853 (*(byte *)var->addr)--; |
853 (*(byte *)var->addr)--; |
854 IConsoleVarDump(var,NULL); |
854 IConsoleVarDump(var,NULL); |
855 } |
855 } |
856 else { IConsoleError("operation not supported"); } |
856 else { IConsoleError("operation not supported"); } |
857 } |
857 } |
858 break; |
858 break; |
859 case ICONSOLE_VAR_UINT16: |
859 case ICONSOLE_VAR_UINT16: |
860 { |
860 { |
1081 if (execution_mode==3) { |
1081 if (execution_mode==3) { |
1082 IConsoleVarFree(result); |
1082 IConsoleVarFree(result); |
1083 result = NULL; |
1083 result = NULL; |
1084 } |
1084 } |
1085 } |
1085 } |
1086 |
1086 |
1087 } |
1087 } |
1088 break; |
1088 break; |
1089 default: |
1089 default: |
1090 { |
1090 { |
1091 // execution mode invalid |
1091 // execution mode invalid |
1127 IConsolePrintF(atoi(argv[1]), argv[2] ,argv[3],argv[4],argv[5],argv[6],argv[7],argv[8],argv[9],argv[10],argv[11],argv[12],argv[13],argv[14],argv[15],argv[16],argv[17],argv[18],argv[19]); |
1127 IConsolePrintF(atoi(argv[1]), argv[2] ,argv[3],argv[4],argv[5],argv[6],argv[7],argv[8],argv[9],argv[10],argv[11],argv[12],argv[13],argv[14],argv[15],argv[16],argv[17],argv[18],argv[19]); |
1128 return NULL; |
1128 return NULL; |
1129 } |
1129 } |
1130 |
1130 |
1131 static _iconsole_var * IConsoleStdLibScreenShot(byte argc, byte* argv[], byte argt[]) { |
1131 static _iconsole_var * IConsoleStdLibScreenShot(byte argc, byte* argv[], byte argt[]) { |
1132 |
1132 |
1133 if (argc<2) { |
1133 if (argc<2) { |
1134 _make_screenshot=1; |
1134 _make_screenshot=1; |
1135 } else { |
1135 } else { |
1136 if (strcmp(argv[1],"big")==0) { |
1136 if (strcmp(argv[1],"big")==0) { |
1137 _make_screenshot=2; |
1137 _make_screenshot=2; |
1199 int l = 0; |
1199 int l = 0; |
1200 |
1200 |
1201 if (argv[1]!=NULL) l = strlen((char *) argv[1]); |
1201 if (argv[1]!=NULL) l = strlen((char *) argv[1]); |
1202 |
1202 |
1203 item = _iconsole_cmds; |
1203 item = _iconsole_cmds; |
1204 while (item != NULL) { |
1204 while (item != NULL) { |
1205 if (argv[1]!=NULL) { |
1205 if (argv[1]!=NULL) { |
1206 |
1206 |
1207 if (memcmp((void *) item->name, (void *) argv[1],l)==0) |
1207 if (memcmp((void *) item->name, (void *) argv[1],l)==0) |
1208 IConsolePrintF(_iconsole_color_default,"%s",item->name); |
1208 IConsolePrintF(_iconsole_color_default,"%s",item->name); |
1209 |
1209 |
1223 int l = 0; |
1223 int l = 0; |
1224 |
1224 |
1225 if (argv[1]!=NULL) l = strlen((char *) argv[1]); |
1225 if (argv[1]!=NULL) l = strlen((char *) argv[1]); |
1226 |
1226 |
1227 item = _iconsole_vars; |
1227 item = _iconsole_vars; |
1228 while (item != NULL) { |
1228 while (item != NULL) { |
1229 if (argv[1]!=NULL) { |
1229 if (argv[1]!=NULL) { |
1230 |
1230 |
1231 if (memcmp((void *) item->name, (void *) argv[1],l)==0) |
1231 if (memcmp((void *) item->name, (void *) argv[1],l)==0) |
1232 IConsolePrintF(_iconsole_color_default,"%s",item->name); |
1232 IConsolePrintF(_iconsole_color_default,"%s",item->name); |
1233 |
1233 |
1247 int l = 0; |
1247 int l = 0; |
1248 |
1248 |
1249 if (argv[1]!=NULL) l = strlen((char *) argv[1]); |
1249 if (argv[1]!=NULL) l = strlen((char *) argv[1]); |
1250 |
1250 |
1251 item = _iconsole_vars; |
1251 item = _iconsole_vars; |
1252 while (item != NULL) { |
1252 while (item != NULL) { |
1253 if (argv[1]!=NULL) { |
1253 if (argv[1]!=NULL) { |
1254 |
1254 |
1255 if (memcmp((void *) item->name, (void *) argv[1],l)==0) |
1255 if (memcmp((void *) item->name, (void *) argv[1],l)==0) |
1256 IConsoleVarDump(item,NULL); |
1256 IConsoleVarDump(item,NULL); |
1257 |
1257 |