@ -212,6 +212,39 @@ parse_overlay_env(struct overlay_params *params,
{
uint32_t num ;
char key [ 256 ] , value [ 256 ] ;
while ( ( num = parse_string ( env , key , value ) ) ! = 0 ) {
env + = num ;
if ( ! strcmp ( " full " , key ) ) {
# define OVERLAY_PARAM_BOOL(name) \
params - > enabled [ OVERLAY_PARAM_ENABLED_ # # name ] = 1 ;
# define OVERLAY_PARAM_CUSTOM(name)
OVERLAY_PARAMS
# undef OVERLAY_PARAM_BOOL
# undef OVERLAY_PARAM_CUSTOM
params - > enabled [ OVERLAY_PARAM_ENABLED_crosshair ] = 0 ;
}
# define OVERLAY_PARAM_BOOL(name) \
if ( ! strcmp ( # name , key ) ) { \
params - > enabled [ OVERLAY_PARAM_ENABLED_ # # name ] = \
strtol ( value , NULL , 0 ) ; \
continue ; \
}
# define OVERLAY_PARAM_CUSTOM(name) \
if ( ! strcmp ( # name , key ) ) { \
params - > name = parse_ # # name ( value ) ; \
continue ; \
}
OVERLAY_PARAMS
# undef OVERLAY_PARAM_BOOL
# undef OVERLAY_PARAM_CUSTOM
fprintf ( stderr , " Unknown option '%s' \n " , key ) ;
}
}
void
parse_overlay_config ( struct overlay_params * params ,
const char * env )
{
memset ( params , 0 , sizeof ( * params ) ) ;
@ -225,6 +258,7 @@ parse_overlay_env(struct overlay_params *params,
params - > enabled [ OVERLAY_PARAM_ENABLED_gpu_stats ] = true ;
params - > enabled [ OVERLAY_PARAM_ENABLED_ram ] = false ;
params - > enabled [ OVERLAY_PARAM_ENABLED_vram ] = false ;
params - > enabled [ OVERLAY_PARAM_ENABLED_read_configs ] = false ;
params - > fps_sampling_period = 500000 ; /* 500ms */
params - > width = 280 ;
params - > height = 140 ;
@ -238,18 +272,26 @@ parse_overlay_env(struct overlay_params *params,
params - > offset_y = 0 ;
params - > background_alpha = 0.5 ;
// first pass with env var
if ( env )
parse_overlay_env ( params , env ) ;
bool rc = params - > enabled [ OVERLAY_PARAM_ENABLED_read_configs ] ;
if ( ! env | | rc ) {
// Get config options
parseConfigFile ( ) ;
if ( options . find ( " full " ) ! = options . end ( ) & & options . find ( " full " ) - > second ! = " 0 " ) {
# define OVERLAY_PARAM_BOOL(name) \
params - > enabled [ OVERLAY_PARAM_ENABLED_ # # name ] = 1 ;
# define OVERLAY_PARAM_CUSTOM(name) //define _CUSTOM to nothing so they are left alone
# define OVERLAY_PARAM_CUSTOM(name)
OVERLAY_PARAMS
# undef OVERLAY_PARAM_BOOL
# undef OVERLAY_PARAM_CUSTOM
params - > enabled [ OVERLAY_PARAM_ENABLED_crosshair ] = 0 ;
options . erase ( " full " ) ;
}
for ( auto & it : options ) {
# define OVERLAY_PARAM_BOOL(name) \
if ( it . first = = # name ) { \
@ -268,37 +310,12 @@ parse_overlay_env(struct overlay_params *params,
fprintf ( stderr , " Unknown option '%s' \n " , it . first . c_str ( ) ) ;
}
if ( env ) {
while ( ( num = parse_string ( env , key , value ) ) ! = 0 ) {
env + = num ;
if ( ! strcmp ( " full " , key ) ) {
# define OVERLAY_PARAM_BOOL(name) \
params - > enabled [ OVERLAY_PARAM_ENABLED_ # # name ] = 1 ;
# define OVERLAY_PARAM_CUSTOM(name) //define _CUSTOM to nothing so they are left alone
OVERLAY_PARAMS
# undef OVERLAY_PARAM_BOOL
# undef OVERLAY_PARAM_CUSTOM
params - > enabled [ OVERLAY_PARAM_ENABLED_crosshair ] = 0 ;
}
# define OVERLAY_PARAM_BOOL(name) \
if ( ! strcmp ( # name , key ) ) { \
params - > enabled [ OVERLAY_PARAM_ENABLED_ # # name ] = \
strtol ( value , NULL , 0 ) ; \
continue ; \
}
# define OVERLAY_PARAM_CUSTOM(name) \
if ( ! strcmp ( # name , key ) ) { \
params - > name = parse_ # # name ( value ) ; \
continue ; \
}
OVERLAY_PARAMS
# undef OVERLAY_PARAM_BOOL
# undef OVERLAY_PARAM_CUSTOM
fprintf ( stderr , " Unknown option '%s' \n " , key ) ;
}
}
// second pass, override config file settings with MANGOHUD_CONFIG
if ( env & & rc )
parse_overlay_env ( params , env ) ;
// if font_size is used and height has not been changed from default
// increase height as needed based on font_size