X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg%2Fvg_console.h;h=48f1f2ec985b1228400f528d7d44dcfb0c5b52bd;hb=e00ea4ccba1891970699f9b5b78ba1ebaada2974;hp=23b4480c2b46a0fa1de59c8535ff83abf4d52662;hpb=a6d22d2e369a955e85d03b1159d4ac02b103ea43;p=fishladder.git diff --git a/vg/vg_console.h b/vg/vg_console.h index 23b4480..48f1f2e 100644 --- a/vg/vg_console.h +++ b/vg/vg_console.h @@ -25,7 +25,7 @@ struct vg_console struct vg_cmd { - void (*function)( int argc, char *argv[] ); + int (*function)( int argc, char const *argv[] ); const char *name; } *functions; @@ -42,7 +42,7 @@ struct vg_console int enabled; int scale; } -vg_console = { .scale = 1 }; +vg_console = { .scale = 2 }; static int vg_console_enabled(void) { return vg_console.enabled; } @@ -102,8 +102,8 @@ static void vg_console_draw( void ) int start = VG_MIN( vg_console.cursor_pos, vg_console.cursor_user ), end = VG_MAX( vg_console.cursor_pos, vg_console.cursor_user ); - ui_global_ctx.cursor[0] = start * 6 * vg_console.scale; - ui_global_ctx.cursor[2] = (start == end? 1: (end-start)) * 6 * vg_console.scale; + ui_global_ctx.cursor[0] = (start * ui_glyph_spacing_x * vg_console.scale)/2 + 2; + ui_global_ctx.cursor[2] = (start == end? 0.2f: (float)(end-start)) * (float)ui_glyph_spacing_x * (float)vg_console.scale * 0.5f; ui_fill_rect( &ui_global_ctx, ui_global_ctx.cursor, 0x66ffffff ); } @@ -121,6 +121,25 @@ void vg_console_println( const char *str ) vg_console.current = 0; } +static int vg_console_list( int argc, char const *argv[] ) +{ + for( int i = 0; i < arrlen( vg_console.functions ); i ++ ) + { + struct vg_cmd *cmd = &vg_console.functions[ i ]; + vg_info( "* %s\n", cmd->name ); + } + + vg_info( "* snowsound\n" ); + + for( int i = 0; i < arrlen( vg_console.convars ); i ++ ) + { + struct vg_convar *cv = &vg_console.convars[ i ]; + vg_info( "%s\n", cv->name ); + } + + return 0; +} + static void vg_console_init(void) { vg_log_callback = vg_console_println; @@ -128,6 +147,11 @@ static void vg_console_init(void) vg_convar_push( (struct vg_convar) { .name = "console_scale", .data = &vg_console.scale, .data_type = k_convar_dtype_i32, .opt_i32 = { .clamp = 1, .min = 1, .max = 7 } } ); + + vg_function_push( (struct vg_cmd){ + .name = "list", + .function = vg_console_list + }); } static void vg_console_free(void) @@ -139,7 +163,7 @@ static void vg_console_free(void) static void execute_console_input( const char *cmd ) { char temp[512]; - char *args[9]; + char const *args[9]; int arg_count = 0; int in_token = 0; @@ -153,6 +177,9 @@ static void execute_console_input( const char *cmd ) { temp[i] = '\0'; in_token = 0; + + if( arg_count == vg_list_size( args ) ) + break; } else { @@ -223,7 +250,7 @@ static void execute_console_input( const char *cmd ) } } - vg_error( "No command/variable named '%s'\n", args[0] ); + vg_error( "No command/variable named '%s'. Use 'list' to view all\n", args[0] ); } // =============================================================================================================================