From: hgn Date: Fri, 29 Dec 2023 11:10:12 +0000 (+0000) Subject: window defaults&persistent X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=commitdiff_plain;h=acdb99e5f0a8bcff01c2eb23e1b5dfdc756190f7 window defaults&persistent --- diff --git a/vg.h b/vg.h index 919f6f3..7822a95 100644 --- a/vg.h +++ b/vg.h @@ -758,47 +758,45 @@ static void _vg_init_window( const char *window_name ) vg.window_x = video_mode.w; vg.window_y = video_mode.h; -#ifdef VG_DEVWINDOW - vg.window_x = 1280; - vg.window_y = 720; -#endif - #ifndef _WIN32 SDL_SetHint( "SDL_VIDEO_X11_XINERAMA", "1" ); SDL_SetHint( "SDL_VIDEO_X11_XRANDR", "0" ); SDL_SetHint( "SDL_VIDEO_X11_XVIDMODE", "0" ); #endif - vg_info( "CreateWindow( %d %d @%dhz )\n", vg.window_x, vg.window_y, - vg.display_refresh_rate ); + u32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_GRABBED; + +#ifdef VG_DEVWINDOW + flags |= SDL_WINDOW_BORDERLESS; + vg.screen_mode = 2; + vg.window_x = 1280; + vg.window_y = 720; +#else + + if( vg.screen_mode == 2 ) + flags |= SDL_WINDOW_RESIZABLE; + else if( vg.screen_mode == 1 ) + flags |= SDL_WINDOW_FULLSCREEN; + else + flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; + +#endif + + vg_info( "CreateWindow( %d %d %u )\n", vg.window_x, vg.window_y, flags ); - /* TODO: Allow selecting closest video mode from launch opts */ if((vg.window = SDL_CreateWindow( window_name, + 0, 0, vg.window_x, vg.window_y, flags ))){ #ifdef VG_DEVWINDOW - 0, 0, vg.window_x, vg.window_y, - SDL_WINDOW_BORDERLESS|SDL_WINDOW_OPENGL|SDL_WINDOW_INPUT_GRABBED - ))){ SDL_SetWindowPosition( vg.window, video_mode.w-vg.window_x, 0 ); - vg.screen_mode = 2; - } -#else - 0, 0, - vg.window_x, vg.window_y, - - SDL_WINDOW_FULLSCREEN_DESKTOP | - SDL_WINDOW_OPENGL | - SDL_WINDOW_INPUT_GRABBED | - SDL_WINDOW_RESIZABLE - ))) - { +#endif + if( SDL_SetWindowDisplayMode( vg.window, &video_mode ) ){ vg_error( "SDL_SetWindowDisplayMode failed: %s", SDL_GetError() ); SDL_Quit(); exit(0); } } -#endif else{ vg_error( "SDL_CreateWindow failed: %s", SDL_GetError() ); exit(0); @@ -850,12 +848,7 @@ static void _vg_init_window( const char *window_name ) } vg_info( "Display refresh rate: %d\n", dispmode.refresh_rate ); - vg.fps_limit = vg.display_refresh_rate; - -#if defined(_WIN32) || defined(VG_DEVWINDOW) -#else - //vg.vsync = 1; -#endif + if( !vg.fps_limit) vg.fps_limit = vg.display_refresh_rate; } static void _vg_terminate(void) @@ -884,8 +877,16 @@ static void vg_enter( int argc, char *argv[], const char *window_name ){ vg_alloc_quota(); _vg_console_init(); - vg_console_reg_var( "fps_limit", &vg.fps_limit, k_var_dtype_i32, 0 ); - vg_console_reg_var( "vsync", &vg.vsync, k_var_dtype_i32, VG_VAR_PERSISTENT ); + vg_console_reg_var( "vg_fps_limit", &vg.fps_limit, + k_var_dtype_i32, VG_VAR_PERSISTENT ); + vg_console_reg_var( "vg_vsync", &vg.vsync, + k_var_dtype_i32, VG_VAR_PERSISTENT ); + vg_console_reg_var( "vg_quality", &vg.quality_profile, + k_var_dtype_i32, VG_VAR_PERSISTENT ); + vg_console_reg_var( "vg_screen_mode", &vg.screen_mode, + k_var_dtype_i32, VG_VAR_PERSISTENT ); + vg_console_load_autos(); + vg_console_reg_cmd( "vg_settings", cmd_vg_settings_toggle, NULL ); _vg_init_window( window_name ); diff --git a/vg_console.h b/vg_console.h index 3112cde..42f79e4 100644 --- a/vg_console.h +++ b/vg_console.h @@ -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 );