window defaults&persistent
[vg.git] / vg_console.h
index 3112cde10ea7a86383a75eb2f00d0a17ca052d5c..42f79e4f35e7c62582bad750798f19cc126b8082 100644 (file)
@@ -79,7 +79,7 @@ static int  _vg_console_list( int argc, char const *argv[] );
 static void _vg_console_init(void);
 static void _vg_console_write_persistent(void);
 static void _vg_console_free(void);
-static void  vg_execute_console_input( const char *cmd );
+static void  vg_execute_console_input( const char *cmd, bool silent );
 
 /*
  * Console interface
@@ -154,6 +154,9 @@ int _test_break( int argc, const char *argv[] ){
 int _vg_console_exec( int argc, const char *argv[] ){
    if( argc < 1 ) return 0;
 
+   int silent=0;
+   if( argc == 2 ) silent=1;
+
    char path[256];
    strcpy( path, "cfg/" );
    strncat( path, argv[0], 250 );
@@ -166,7 +169,7 @@ int _vg_console_exec( int argc, const char *argv[] ){
                        line[ strcspn( line, "\r\n#" ) ] = 0x00;
 
                        if( line[0] != 0x00 ){
-                               vg_execute_console_input( line );
+                               vg_execute_console_input( line, silent );
                        }
                }
 
@@ -209,7 +212,7 @@ static void _vg_console_init(void){
 }
 
 static void vg_console_load_autos(void){
-   _vg_console_exec( 1, (const char *[]){ "auto.conf" } );
+   _vg_console_exec( 2, (const char *[]){ "auto.conf", "silent" } );
 }
 
 static void _vg_console_write_persistent(void){
@@ -310,7 +313,7 @@ static vg_cmd *vg_console_match_cmd( const char *kw )
    return NULL;
 }
 
-static void vg_execute_console_input( const char *cmd )
+static void vg_execute_console_input( const char *cmd, bool silent )
 {
        char temp[512];
        char const *args[8];
@@ -328,7 +331,7 @@ static void vg_execute_console_input( const char *cmd )
       /* Cvar Matched, try get value */
       if( arg_count >= 2 ){
          if( cv->flags & VG_VAR_CHEAT ){
-            if( !vg_console.cheats ){
+            if( !vg_console.cheats && !silent ){
                vg_error( "variable is cheat protected\n" );
                return;
             }
@@ -367,7 +370,8 @@ static void vg_execute_console_input( const char *cmd )
       return;
    }
        
-       vg_error( "No command/var named '%s'. Use 'list' to view all\n", args[0] );
+   if( !silent )
+      vg_error( "No command/var named '%s'. Use 'list' to view all\n",args[0]);
 }
 
 u32 str_lev_distance( const char *s1, const char *s2 ){
@@ -671,7 +675,7 @@ static void _vg_console_on_enter( char *buf, u32 len )
       }
 
       vg_console.history_pos = -1;
-      vg_execute_console_input( vg_console.input );
+      vg_execute_console_input( vg_console.input, 0 );
       _ui_textbox_move_cursor( &vg_ui.textbox.cursor_user,
                                &vg_ui.textbox.cursor_pos, -10000, 1 );